BlueGit

ict rusty-teams

fix(calling): fail stay-awake spawn when PDEATHSIG cannot be set

Copilot review on #42: ignoring prctl failure would leave sleep infinity
orphaned after a parent crash — the whole reason for PR_SET_PDEATHSIG.

metis Joachim Mild · pushed by metis

Authored 2026-11-15 · 2 weeks ago

Hash
bf15f9fad432a70c8bdd12d45937ffb35574dc14
Parent
36a4a3a0
1 file changed +5 −1
crates/calling/src/awake.rs +5 −1
@@ -77,7 +77,11 @@ impl StayAwake {
77 77 // SAFETY: pre_exec runs in the child before exec; PR_SET_PDEATHSIG is process-local.
78 78 unsafe {
79 79 command.pre_exec(|| {
80 libc::prctl(libc::PR_SET_PDEATHSIG, libc::SIGTERM);
80 // Fail spawn if PDEATHSIG cannot be armed — otherwise a crash can leave
81 // `sleep infinity` orphaned under systemd-inhibit.
82 if libc::prctl(libc::PR_SET_PDEATHSIG, libc::SIGTERM) != 0 {
83 return Err(std::io::Error::last_os_error());
84 }
81 85 Ok(())
82 86 });
83 87 }
@@ -77,7 +77,11 @@ impl StayAwake {
77 // SAFETY: pre_exec runs in the child before exec; PR_SET_PDEATHSIG is process-local.
77 // SAFETY: pre_exec runs in the child before exec; PR_SET_PDEATHSIG is process-local.
78 unsafe {
78 unsafe {
79 command.pre_exec(|| {
79 command.pre_exec(|| {
80 libc::prctl(libc::PR_SET_PDEATHSIG, libc::SIGTERM);
80 // Fail spawn if PDEATHSIG cannot be armed — otherwise a crash can leave
81 // `sleep infinity` orphaned under systemd-inhibit.
82 if libc::prctl(libc::PR_SET_PDEATHSIG, libc::SIGTERM) != 0 {
83 return Err(std::io::Error::last_os_error());
84 }
81 Ok(())
85 Ok(())
82 });
86 });
83 }
87 }