fix: reap zombie Chrome process and fast-detect crash for auto-restart (#1023)
When Chrome crashes (e.g. SIGTRAP from CHECK() assertion), the daemon now: 1. Reaps the zombie immediately via a SIGCHLD handler in the event loop that calls waitpid(-1, WNOHANG) 2. Detects the crash instantly on the next command via a non-blocking try_wait() check (has_process_exited), avoiding the 3-second CDP timeout that is_connection_alive() would incur 3. Auto-relaunches Chrome transparently for the caller Fixes #1017 Co-authored-by: ctate <366502+ctate@users.noreply.github.com>
This commit is contained in:
@@ -17,6 +17,17 @@ impl ChromeProcess {
|
||||
let _ = self.child.wait();
|
||||
}
|
||||
|
||||
/// Returns the OS process ID of the Chrome child process.
|
||||
pub fn id(&self) -> u32 {
|
||||
self.child.id()
|
||||
}
|
||||
|
||||
/// Non-blocking check whether Chrome has exited.
|
||||
/// Returns `true` if the process has exited (and reaps it), `false` if still running.
|
||||
pub fn has_exited(&mut self) -> bool {
|
||||
matches!(self.child.try_wait(), Ok(Some(_)) | Err(_))
|
||||
}
|
||||
|
||||
/// Wait for Chrome to exit on its own (after Browser.close CDP command),
|
||||
/// falling back to kill() if it doesn't exit within the timeout.
|
||||
/// This allows Chrome to flush cookies and other state to the user-data-dir.
|
||||
|
||||
Reference in New Issue
Block a user