single system call for signal blocking

This commit is contained in:
Simon Cruanes 2025-03-13 15:42:04 -04:00
parent dd88008a0a
commit f0ea8c294d
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -103,19 +103,22 @@ let with_handler ~ops:_ self f = f ()
[@@@endif]
let worker_loop (type st) ~block_signals ~(ops : st ops) (self : st) : unit =
if block_signals then
List.iter
(fun signal -> try Sys.set_signal signal Sys.Signal_ignore with _ -> ())
[
Sys.sigterm;
Sys.sigpipe;
Sys.sigint;
Sys.sigchld;
Sys.sigalrm;
Sys.sigusr1;
Sys.sigusr2;
Sys.sigvtalrm;
];
if block_signals then (
try
ignore
(Unix.sigprocmask SIG_BLOCK
[
Sys.sigterm;
Sys.sigpipe;
Sys.sigint;
Sys.sigchld;
Sys.sigalrm;
Sys.sigusr1;
Sys.sigusr2;
]
: _ list)
with _ -> ()
);
let cur_fiber : fiber ref = ref _dummy_fiber in
let runner = ops.runner self in