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.
@@ -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 leave81
// `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
}