Unix.SignalWaiting 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).
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.
val wait' : Stdlib.Sys.signal -> 'tag -> 'tag Affect.Action.tval set : Stdlib.Sys.signal -> handler -> unitset signal h sets the handler of signal to h.
val set_and_restore : Stdlib.Sys.signal -> handler -> (unit -> 'a) -> 'aset_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.