package affect
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=b328f6696e60c489da8cc2e8fad0537ca6634a39fc0c5de5840d4f98561f110617ef79ba8285ee8427dd99908c6b3d39114973598cddc5ded91abcce3b91b9a6
doc/affect.unix/Affect_unix/Unix/Signal/index.html
Module Unix.SignalSource
Waiting on signals.
Warning. This uses the OCaml signal handlers of Sys which are global variables. If you don't get what you want check that no other part of the program is trying to Sys.signal or Sys.set_signal.
Implementation note. Theoretically this should work reliably regardless on how signal delivery is configured in the program. The Signal.handler.Waiters signal handling mode integrates into the file descriptor watching infrastructure via a socket created with Unix.socketpair (self-pipe trick).
Waiting
wait_any signals waits for the next occurence of a signal in signals whose handler is Waiters at occurence time and continues with the signal that did.
Actions
Handling
type handler = | Default(*Default signal hander, usually abort the program.
*)| Ignore(*Ignore the signal.
*)| Fun of Sys.signal -> unit(*Call the given function with the signal number.
*)| Waiters
set signal h sets the handler of signal to h.
set_and_restore signal b f gets the handler for signal as current, sets the handler of signal to b, calls f () and sets the handler of signal back to current after f returned or raised.
Warning. Signal handlers are global, there is no notion of scope here. If someone sets signal in parallel these changes will also be visible in f.
Formatting
pp formats signals for inspection.