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:
@@ -180,6 +180,14 @@ impl BrowserProcess {
|
||||
BrowserProcess::Lightpanda(p) => p.kill(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Non-blocking check whether the browser process has exited.
|
||||
pub fn has_exited(&mut self) -> bool {
|
||||
match self {
|
||||
BrowserProcess::Chrome(p) => p.has_exited(),
|
||||
BrowserProcess::Lightpanda(_) => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BrowserManager {
|
||||
@@ -643,6 +651,17 @@ impl BrowserManager {
|
||||
}
|
||||
}
|
||||
|
||||
/// Non-blocking check whether the locally-launched browser process has exited
|
||||
/// (crashed or terminated). Also reaps the zombie if it has exited.
|
||||
/// Returns false for external CDP connections (no child process to monitor).
|
||||
pub fn has_process_exited(&mut self) -> bool {
|
||||
if let Some(ref mut process) = self.browser_process {
|
||||
process.has_exited()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_cdp_url(&self) -> &str {
|
||||
&self.ws_url
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user