module Signal: Signal
type
t
include Comparable.S
include Hashable.S
include Stringable.S
val equal : t -> t -> bool
val of_system_int : int -> t
of_system_int
and to_system_int
return and take respectively a signal number
corresponding to those in the system's /usr/include/bits/signum.h (or equivalent). It
is not guaranteed that these numbers are portable across any given pair of systems --
although some are defined as standard by POSIX.val to_system_int : t -> int
val of_caml_int : int -> t
of_caml_int
constructs a Signal.t given an O'Caml internal signal number. This is
only for the use of the Core_unix module.val to_caml_int : t -> int
val to_string : t -> string
to_string t
returns a human-readable name: "sigabrt", "sigalrm", ...typesys_behavior =
[ `Continue | `Dump_core | `Ignore | `Stop | `Terminate ]
val default_sys_behavior : t -> sys_behavior
default_sys_behavior t
Query the default system behavior for a signal.val handle_default : t -> unit
handle_default t
is set t `Default
.val ignore : t -> unit
ignore t
is set t `Ignore
.typepid_spec =
[ `Group of Core_kernel.Std.Pid.t | `My_group | `Pid of Core_kernel.Std.Pid.t ]
val send : t -> pid_spec -> [ `No_such_process | `Ok ]
send signal pid
sends signal
to the process whose process id is pid
.val send_i : t -> pid_spec -> unit
send_i signal ~pid
sends signal
to the process whose process id is pid
.
* No exception will be raised if pid
is a zombie or nonexistent.val send_exn : t -> pid_spec -> unit
send_exn signal ~pid
sends signal
to the process whose process id is
* pid
. In Caml's standard library, this is called Unix.kill
. Sending a
* signal to a zombie and/or nonexistent process will raise an exception.val can_send_to : Core_kernel.Std.Pid.t -> bool
can_send_to pid
returns true if pid
is running and the current process has
permission to send it signals.typesigprocmask_command =
[ `Block | `Set | `Unblock ]
val sigprocmask : sigprocmask_command -> t list -> t list
sigprocmask cmd sigs
changes the set of blocked signals.
* If cmd
is `Set
, blocked signals are set to those in the list sigs
.
* If cmd
is `Block
, the signals in sigs
are added to the set of blocked
* signals.
* If cmd
is `Unblock
, the signals in sigs
are removed from the set of
* blocked signals.
* sigprocmask
returns the set of previously blocked signals.val sigpending : unit -> t list
sigpending ()
returns the set of blocked signals that are currently
* pending.val sigsuspend : t list -> unit
sigsuspend sigs
atomically sets the blocked signals to sigs
and waits for
* a non-ignored, non-blocked signal to be delivered. On return, the blocked
* signals are reset to their initial value.val abrt : t
Dump_core
Abnormal terminationval alrm : t
Terminate
Timeoutval chld : t
Ignore
Child process terminatedval cont : t
Continue
Continueval fpe : t
Dump_core
Arithmetic exceptionval hup : t
Terminate
Hangup on controlling terminalval ill : t
Dump_core
Invalid hardware instructionval int : t
Terminate
Interactive interrupt (ctrl-C)val kill : t
Terminate
Termination (cannot be ignored)val pipe : t
Terminate
Broken pipeval prof : t
Terminate
Profiling interruptval quit : t
Dump_core
Interactive terminationval segv : t
Dump_core
Invalid memory referenceval stop : t
Stop
Stopval term : t
Terminate
Terminationval tstp : t
Stop
Interactive stopval ttin : t
Stop
Terminal read from background processval ttou : t
Stop
Terminal write from background processval usr1 : t
Terminate
Application-defined signal 1val usr2 : t
Terminate
Application-defined signal 2val vtalrm : t
Terminate
Timeout in virtual timeval zero : t
Ignore
No-op; can be used to test whether the target
process exists and the current process has
permission to signal itmodule Expert:sig
..end
Expert
module contains functions that novice users should avoid, due to their
complexity.
val t_of_sexp : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
val bin_t : t Core_kernel.Std.Bin_prot.Type_class.t
val bin_read_t : t Core_kernel.Std.Bin_prot.Read.reader
val __bin_read_t__ : (int -> t) Core_kernel.Std.Bin_prot.Read.reader
val bin_reader_t : t Core_kernel.Std.Bin_prot.Type_class.reader
val bin_size_t : t Core_kernel.Std.Bin_prot.Size.sizer
val bin_write_t : t Core_kernel.Std.Bin_prot.Write.writer
val bin_writer_t : t Core_kernel.Std.Bin_prot.Type_class.writer
of_system_int
and to_system_int
return and take respectively a signal number
corresponding to those in the system's /usr/include/bits/signum.h (or equivalent). It
is not guaranteed that these numbers are portable across any given pair of systems --
although some are defined as standard by POSIX.of_caml_int
constructs a Signal.t given an O'Caml internal signal number. This is
only for the use of the Core_unix module.to_string t
returns a human-readable name: "sigabrt", "sigalrm", ...val sys_behavior_of_sexp : Sexplib.Sexp.t -> sys_behavior
val __sys_behavior_of_sexp__ : Sexplib.Sexp.t -> sys_behavior
val sexp_of_sys_behavior : sys_behavior -> Sexplib.Sexp.t
default_sys_behavior t
Query the default system behavior for a signal.handle_default t
is set t `Default
.ignore t
is set t `Ignore
.send signal pid
sends signal
to the process whose process id is pid
.send_i signal ~pid
sends signal
to the process whose process id is pid
.
* No exception will be raised if pid
is a zombie or nonexistent.send_exn signal ~pid
sends signal
to the process whose process id is
* pid
. In Caml's standard library, this is called Unix.kill
. Sending a
* signal to a zombie and/or nonexistent process will raise an exception.can_send_to pid
returns true if pid
is running and the current process has
permission to send it signals.sigprocmask cmd sigs
changes the set of blocked signals.
* If cmd
is `Set
, blocked signals are set to those in the list sigs
.
* If cmd
is `Block
, the signals in sigs
are added to the set of blocked
* signals.
* If cmd
is `Unblock
, the signals in sigs
are removed from the set of
* blocked signals.
* sigprocmask
returns the set of previously blocked signals.sigpending ()
returns the set of blocked signals that are currently
* pending.sigsuspend sigs
atomically sets the blocked signals to sigs
and waits for
* a non-ignored, non-blocked signal to be delivered. On return, the blocked
* signals are reset to their initial value.Dump_core
Abnormal terminationTerminate
TimeoutIgnore
Child process terminatedContinue
ContinueDump_core
Arithmetic exceptionTerminate
Hangup on controlling terminalDump_core
Invalid hardware instructionTerminate
Interactive interrupt (ctrl-C)Terminate
Termination (cannot be ignored)Terminate
Broken pipeTerminate
Profiling interruptDump_core
Interactive terminationDump_core
Invalid memory referenceStop
StopTerminate
TerminationStop
Interactive stopStop
Terminal read from background processStop
Terminal write from background processTerminate
Application-defined signal 1Terminate
Application-defined signal 2Terminate
Timeout in virtual timeIgnore
No-op; can be used to test whether the target
process exists and the current process has
permission to signal itExpert
module contains functions that novice users should avoid, due to their
complexity.
An OCaml signal handler can run at any time, which introduces all the semantic
complexities of multithreading. It is much easier to use async signal handling, see
Async_unix.Signal
, which does not involve multithreading, and runs user code as
ordinary async jobs. Also, beware that there can only be a single OCaml signal
handler for any signal, so handling a signal with a Core
signal handler will
interfere if async is attempting to handle the same signal.
If you do use Core
signal handlers, you should strive to make the signal handler
perform a simple idempotent action, like setting a ref.
signal t
sets the behavior of the system on receipt of signal t
and returns the
behavior previously associated with t
. If t
is not available on your system,
signal
raises.
set t b
is ignore (signal t b)
handle t f
is set t (`Handle f)
.