mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
more signal handling
This commit is contained in:
parent
794b263d36
commit
b1688f71e7
3 changed files with 17 additions and 21 deletions
|
|
@ -144,22 +144,7 @@ module Fine_grained (Args : FINE_GRAINED_ARGS) () = struct
|
||||||
if !state <> New then invalid_arg "worker_loop.setup: not a new instance";
|
if !state <> New then invalid_arg "worker_loop.setup: not a new instance";
|
||||||
state := Ready;
|
state := Ready;
|
||||||
|
|
||||||
if block_signals then (
|
if block_signals then Signals_.ignore_signals_ ();
|
||||||
try
|
|
||||||
ignore
|
|
||||||
(Unix.sigprocmask SIG_BLOCK
|
|
||||||
[
|
|
||||||
Sys.sigterm;
|
|
||||||
Sys.sigpipe;
|
|
||||||
Sys.sigint;
|
|
||||||
Sys.sigchld;
|
|
||||||
Sys.sigalrm;
|
|
||||||
Sys.sigusr1;
|
|
||||||
Sys.sigusr2;
|
|
||||||
]
|
|
||||||
: _ list)
|
|
||||||
with _ -> ()
|
|
||||||
);
|
|
||||||
|
|
||||||
TLS.set Runner.For_runner_implementors.k_cur_runner runner;
|
TLS.set Runner.For_runner_implementors.k_cur_runner runner;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,11 +99,7 @@ let domains_ : (worker_state option * Domain_.t option) Lock.t array =
|
||||||
a [Pool.with_] or [Pool.create() … Pool.shutdown()] in a tight loop), and
|
a [Pool.with_] or [Pool.create() … Pool.shutdown()] in a tight loop), and
|
||||||
if nothing happens it tries to stop to free resources. *)
|
if nothing happens it tries to stop to free resources. *)
|
||||||
let work_ idx (st : worker_state) : unit =
|
let work_ idx (st : worker_state) : unit =
|
||||||
Thread.sigmask SIG_BLOCK
|
Signals_.ignore_signals_ ();
|
||||||
[
|
|
||||||
Sys.sigpipe; Sys.sigbus; Sys.sigterm; Sys.sigint; Sys.sigusr1; Sys.sigusr2;
|
|
||||||
]
|
|
||||||
|> ignore;
|
|
||||||
let main_loop () =
|
let main_loop () =
|
||||||
let continue = ref true in
|
let continue = ref true in
|
||||||
while !continue do
|
while !continue do
|
||||||
|
|
|
||||||
15
src/private/signals_.ml
Normal file
15
src/private/signals_.ml
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
let ignore_signals_ () =
|
||||||
|
try
|
||||||
|
Thread.sigmask SIG_BLOCK
|
||||||
|
[
|
||||||
|
Sys.sigpipe;
|
||||||
|
Sys.sigbus;
|
||||||
|
Sys.sigterm;
|
||||||
|
Sys.sigchld;
|
||||||
|
Sys.sigalrm;
|
||||||
|
Sys.sigint;
|
||||||
|
Sys.sigusr1;
|
||||||
|
Sys.sigusr2;
|
||||||
|
]
|
||||||
|
|> ignore
|
||||||
|
with _ -> ()
|
||||||
Loading…
Add table
Reference in a new issue