Skip to main content

wrap_with_abort_marker

Function wrap_with_abort_marker 

Source
pub fn wrap_with_abort_marker(command: &str, marker: &str) -> String
Expand description

Wraps command so the remote process carries marker in its argv.

sh -c '<command>' '<marker>' runs the command unchanged and binds the marker to $0, which is what lands in /proc/<pid>/cmdline and therefore what pkill -f can match. The marker is not a secret and never carries one.

Caveat kept deliberately: only processes whose argv contains the marker are reachable by the abort, i.e. the wrapper shell and anything that inherits the text. Grandchildren that re-exec with a fresh argv survive. Leaking a stray child is strictly safer than the previous behaviour of killing third-party processes.