Skip to main content

signal_same_process

Function signal_same_process 

Source
pub fn signal_same_process(
    pid: u32,
    expected: &ProcessIdentity,
    signal: StopSignal,
) -> bool
Expand description

Deliver signal to pid only while it is still the process expected describes. True when the signal was delivered.

The check and the signal are bound to one process object wherever the OS allows it, so a PID recycled in between is never hit:

  • Windows: one handle opened with query and terminate rights; the identity is read through that handle and TerminateProcess uses it.
  • Linux: a pidfd is opened first, the identity checked, then pidfd_send_signal targets the pidfd (kernel ≥ 5.3; older kernels fall back to the re-check + kill below).
  • macOS and other Unix: the identity is re-checked immediately before kill; the remaining window is microseconds.