This commit is contained in:
Timon
2026-07-10 00:52:06 +00:00
parent 5daea64585
commit 9b8919047f
3 changed files with 21 additions and 21 deletions
+3 -3
View File
@@ -5,15 +5,15 @@ use std::process::Command;
use crate::frames::plane;
pub(crate) fn setup_command(command: &mut Command, #[cfg(feature = "accelerated_paint")] host_frame_fd: Option<std::os::fd::RawFd>) {
let parent_pid = std::process::id() as libc::pid_t;
let main_pid = std::process::id() as libc::pid_t;
// SAFETY: the closure runs in the forked child before exec and only makes async-signal-safe calls
unsafe {
command.pre_exec(move || {
// Tie the host's lifetime to the parent process
// Tie the host's lifetime to the main process
if libc::prctl(libc::PR_SET_PDEATHSIG, libc::SIGKILL) != 0 {
return Err(std::io::Error::last_os_error());
}
if libc::getppid() != parent_pid {
if libc::getppid() != main_pid {
return Err(std::io::Error::other("main process died before PDEATHSIG was set"));
}
+2 -2
View File
@@ -51,13 +51,13 @@ pub(crate) fn spawn_parent_watchdog(main_pid: u32) {
loop {
// SAFETY: getppid is always safe to call.
if unsafe { libc::getppid() } as u32 != main_pid {
tracing::warn!("Main process is gone, exiting CEF host");
tracing::warn!("Parent process is gone, exiting...");
std::process::exit(0);
}
std::thread::sleep(Duration::from_millis(500));
}
});
if let Err(e) = result {
tracing::error!("Failed to spawn the parent watchdog: {e}");
tracing::error!("Failed to spawn parent watchdog: {e}");
}
}