Function signal::exec_handler::set_handler[][src]

pub fn set_handler(signals: &[Signal], avoid_race_condition: bool) -> Result<()>

Set a handler for multiple signals. If no set_command_line was called before this function the command-line is set from std::env

The avoid_race_condition fixes race condition when one of the signals in set is delivered second time before the new process is able to set signal handler itself (most probably leading to process death). But if it’s set to true process is started with another signal mask, so it should fix signal mask (which this function does too).

In other words avoid_race_condition=true is useful is the same program is executed and it calls set_handler on early startup.

For avoid_race_condition=true is also important to use single call for set_handler for all signals, because it avoids race condition between all combinations of subsequent signals in the set.

Since version v0.3.0 command-line is executed only if pid of a process matches original pid where set_handler was called. I.e. you need to set_handler again for forked process if that is desired.