Up

Module Signal = Async_unix.Signal

Signature

include module type of Core.Std.Signal with type t = Core.Std.Signal.t
val t_of_sexp : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
val __bin_read_t__ : (int -> t) Core_kernel.Std.Bin_prot.Read.reader
include Core_kernel.Std.Comparable.S with type t := t
include Comparable_intf.S_common
include Comparable_intf.Polymorphic_compare
include Polymorphic_compare_intf.Infix
type t
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (=) : t -> t -> bool
val (>) : t -> t -> bool
val (<) : t -> t -> bool
val (<>) : t -> t -> bool
val equal : t -> t -> bool
val compare : t -> t -> int
val min : t -> t -> t
val max : t -> t -> t
val ascending : t -> t -> int

ascending is identical to compare. descending x y = ascending y x. These are intended to be mnemonic when used like List.sort ~cmp:ascending and List.sort ~cmp:descending, since they cause the list to be sorted in ascending or descending order, respectively.

val descending : t -> t -> int
val between : t -> low:t -> high:t -> bool
val clamp_exn : t -> min:t -> max:t -> t

clamp_exn t ~min ~max returns t', the closest value to t such that between t' ~low:min ~high:max is true.

Raises if not (min <= max).

val clamp : t -> min:t -> max:t -> t Or_error.t
include Comparator.S with type t := t
type t
type comparator_witness
include Comparable_intf.Validate with type t := t
type t
val validate_lbound : min:t Maybe_bound.t -> t Validate.check
val validate_ubound : max:t Maybe_bound.t -> t Validate.check
val validate_bound : min:t Maybe_bound.t -> max:t Maybe_bound.t -> t Validate.check
include Core_kernel.Std.Hashable.S with type t := t
type t
val hash : t -> int
val compare : t -> t -> int
module Table : Hashable.Hashtbl.S with type key = t
module Hash_set : Core_kernel.Hash_set.S with type elt = t
include Core_kernel.Std.Stringable.S with type t := t
type t
val of_string : string -> t
val to_string : t -> string
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", ...

type sys_behavior = [
| `Continue
| `Dump_core
| `Ignore
| `Stop
| `Terminate
]

The default behaviour of the system if these signals trickle to the top level of a program. See include/linux/kernel.h in the Linux kernel source tree (not the file /usr/include/linux/kernel.h).

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
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.

type pid_spec = [
| `My_group
| `Group of Core_kernel.Std.Pid.t
]
val sexp_of_pid_spec : pid_spec -> Sexplib.Sexp.t
val send : t -> pid_spec -> [
| `Ok
| `No_such_process
]

send signal pid_spec sends signal to the processes specified by pid_spec.

send_i is like send, except that it silently returns if the specified processes don't exist.

send_exn is like send, except that it raises if the specified processes don't exist.

All of send, send_i, and send_exn raise if you don't have permission to send the signal to the specified processes or if signal is unknown.

val send_i : t -> pid_spec -> unit
val send_exn : t -> pid_spec -> unit
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.

type sigprocmask_command = [
| `Set
| `Block
| `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.

Specific signals, along with their default behavior and meaning.

val abrt : t

Dump_core Abnormal termination

val alrm : t

Dump_core Abnormal termination

Terminate Timeout

val chld : t

Terminate Timeout

Ignore Child process terminated

val cont : t

Ignore Child process terminated

Continue Continue

val fpe : t

Continue Continue

Dump_core Arithmetic exception

val hup : t

Dump_core Arithmetic exception

Terminate Hangup on controlling terminal

val ill : t

Terminate Hangup on controlling terminal

Dump_core Invalid hardware instruction

val int : t

Dump_core Invalid hardware instruction

Terminate Interactive interrupt (ctrl-C)

val kill : t

Terminate Interactive interrupt (ctrl-C)

Terminate Termination (cannot be ignored)

val pipe : t

Terminate Termination (cannot be ignored)

Terminate Broken pipe

val prof : t

Terminate Broken pipe

Terminate Profiling interrupt

val quit : t

Terminate Profiling interrupt

Dump_core Interactive termination

val segv : t

Dump_core Interactive termination

Dump_core Invalid memory reference

val stop : t

Dump_core Invalid memory reference

Stop Stop

val term : t

Stop Stop

Terminate Termination

val tstp : t

Terminate Termination

Stop Interactive stop

val ttin : t

Stop Interactive stop

Stop Terminal read from background process

val ttou : t

Stop Terminal read from background process

Stop Terminal write from background process

val usr1 : t

Stop Terminal write from background process

Terminate Application-defined signal 1

val usr2 : t

Terminate Application-defined signal 1

Terminate Application-defined signal 2

val vtalrm : t

Terminate Application-defined signal 2

Terminate Timeout in virtual time

val zero : t

Terminate Timeout in virtual time

Ignore No-op; can be used to test whether the target process exists and the current process has permission to signal it

module Expert : sig .. end
The Expert module contains functions that novice users should avoid, due to their complexity.
val handle_default : [
| `Do_not_use_with_async
] -> _

We override values from Core.Std.Signal that we don't want people to use with Async.

val ignore : [
| `Do_not_use_with_async
] -> _
val handle : ?stop:unit Async_unix.Import.Deferred.t -> t list -> f:(t -> unit) -> unit

handle ?stop signals ~f arranges so that whenever a signal in signals is delivered, f is called on that signal. If f raises, then an exception will be raised to the monitor in effect when handle was called.

Multiple calls to handle with the same signal will cause all the handlers to run when that signal is delivered, not just the last handler from the last call to handle.

The first time handle is called for a signal, it will install a C signal handler for that signal, which will replace the existing C signal handler for that signal.

val terminating : t list

terminating is a list of signals that can be supplied to handle and whose default behavior is to terminate the program: alrm hup int term usr1 usr2.

Various signals whose default_sys_behavior is `Terminate are not included:

| kill | it's not allowed to be handled | | pipe | Async already ignores this signal, since it handles EPIPE | | prof | so that we can profile things with -p | | vtalrm | it already has a handler |

val is_managed_by_async : t -> bool

is_managed_by_async signal returns true iff signal is being managed by Async, and hence its default behavior is no longer in effect.