Skip to content

Commit ea28b4e

Browse files
committed
add Imandrakit_io.block_signals
1 parent 93ea848 commit ea28b4e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/io/imandrakit_io.ml

+15
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@ let with_signal ?(signal = Sys.sigint) ~on_sig f =
7979
let block_sigpipe_sigint () =
8080
ignore (Thread.sigmask Unix.SIG_BLOCK [ Sys.sigint; Sys.sigpipe ] : _ list)
8181

82+
let block_signals () =
83+
ignore
84+
(Unix.sigprocmask Unix.SIG_BLOCK
85+
[
86+
Sys.sigterm;
87+
Sys.sigpipe;
88+
Sys.sigint;
89+
Sys.sigchld;
90+
Sys.sigalrm;
91+
Sys.sigusr1;
92+
Sys.sigusr2;
93+
Sys.sigvtalrm;
94+
]
95+
: _ list)
96+
8297
let read_i32_framed ic : string =
8398
let buf_len = Bytes.create 4 in
8499
really_input ic buf_len 0 4;

src/io/imandrakit_io.mli

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ val with_signal : ?signal:int -> on_sig:(int -> unit) -> (unit -> 'a) -> 'a
4141
val block_sigpipe_sigint : unit -> unit
4242
(** Block these signals in this thread *)
4343

44+
val block_signals : unit -> unit
45+
(** Block a reasonable collection of signals in this thread *)
46+
4447
val read_i32_framed : in_channel -> string
4548
(** [read_i32_framed ic] reads a int32_le-framed message from [ic] *)
4649

0 commit comments

Comments
 (0)