use named signals

This commit is contained in:
Corentin Leruth 2023-08-26 07:06:51 +02:00 committed by Simon Cruanes
parent 83b9837778
commit 9ba1719795

View file

@ -66,8 +66,17 @@ end
(** start a thread in the background, running [f()] *) (** start a thread in the background, running [f()] *)
let start_bg_thread (f : unit -> unit) : Thread.t = let start_bg_thread (f : unit -> unit) : Thread.t =
let run () = let run () =
(* block some signals: USR1 USR2 TERM PIPE ALARM STOP, see [$ kill -L] *) let signals =
ignore (Thread.sigmask Unix.SIG_BLOCK [ 10; 12; 13; 14; 15; 19 ] : _ list); [
Sys.sigusr1;
Sys.sigusr2;
Sys.sigterm;
Sys.sigpipe;
Sys.sigalrm;
Sys.sigstop;
]
in
ignore (Thread.sigmask Unix.SIG_BLOCK signals : _ list);
f () f ()
in in
Thread.create run () Thread.create run ()