pub unsafe fn sigaction(
signal: Signal,
sigaction: &SigAction
) -> Result<SigAction>
Expand description
Changes the action taken by a process on receipt of a specific signal.
signal
can be any signal except SIGKILL
or SIGSTOP
. On success, it returns the previous
action for the given signal. If sigaction
fails, no new signal handler is installed.
§Safety
-
Signal handlers may be called at any point during execution, which limits what is safe to do in the body of the signal-catching function. Be certain to only make syscalls that are explicitly marked safe for signal handlers and only share global data using atomics.
-
There is also no guarantee that the old signal handler was installed correctly. If it was installed by this crate, it will be. But if it was installed by, for example, C code, then there is no guarantee its function pointer is valid. In that case, this function effectively dereferences a raw pointer of unknown provenance.