Module Posix_signal

POSIX signal handling bindings.

This module provides OCaml bindings to POSIX signal functions defined in signal.h.

It includes functions for manipulating signal sets and controlling signal delivery to threads and processes.

Signal Sets

type sigset

Abstract type representing a set of signals.

type signal = [
  1. | `Sigabrt
    (*

    Abnormal termination

    *)
  2. | `Sigalrm
    (*

    Alarm clock

    *)
  3. | `Sigbus
    (*

    Bus error

    *)
  4. | `Sigchld
    (*

    Child process terminated

    *)
  5. | `Sigcont
    (*

    Continue if stopped

    *)
  6. | `Sigfpe
    (*

    Floating-point exception

    *)
  7. | `Sighup
    (*

    Hangup

    *)
  8. | `Sigill
    (*

    Illegal instruction

    *)
  9. | `Sigint
    (*

    Interactive attention signal

    *)
  10. | `Sigkill
    (*

    Kill (cannot be caught or ignored)

    *)
  11. | `Sigpipe
    (*

    Broken pipe

    *)
  12. | `Sigquit
    (*

    Quit

    *)
  13. | `Sigsegv
    (*

    Segmentation fault

    *)
  14. | `Sigstop
    (*

    Stop (cannot be caught or ignored)

    *)
  15. | `Sigterm
    (*

    Termination request

    *)
  16. | `Sigtstp
    (*

    Terminal stop

    *)
  17. | `Sigttin
    (*

    Background read from terminal

    *)
  18. | `Sigttou
    (*

    Background write to terminal

    *)
  19. | `Sigusr1
    (*

    User-defined signal 1

    *)
  20. | `Sigusr2
    (*

    User-defined signal 2

    *)
  21. | `Sigtrap
    (*

    Trace/breakpoint trap

    *)
  22. | `Sigurg
    (*

    Urgent data on socket

    *)
  23. | `Sigxcpu
    (*

    CPU time limit exceeded

    *)
  24. | `Sigxfsz
]

POSIX signals.

File size limit exceeded

Signal Mask Actions

type action = [
  1. | `Sig_block
    (*

    Add signals to the mask

    *)
  2. | `Sig_setmask
    (*

    Set the mask to the specified signals

    *)
  3. | `Sig_unblock
    (*

    Remove signals from the mask

    *)
]

Actions for modifying the signal mask.

Signal Set Functions

val sigemptyset : unit -> sigset

Create an empty signal set. See sigemptyset(3).

val sigaddset : sigset -> signal -> unit

Add a signal to a signal set. See sigaddset(3).

val sigismember : sigset -> signal -> bool

Test whether a signal is in a signal set. See sigismember(3).

Signal Mask Functions

val pthread_sigmask : action -> sigset option -> sigset

Examine and change the signal mask of the calling thread.

See pthread_sigmask(3).

  • parameter action

    How to modify the signal mask.

  • parameter set

    The signal set to use, or None to only retrieve the current mask.

  • returns

    The previous signal mask.

val sigprocmask : action -> sigset option -> sigset

Examine and change the signal mask of the calling process.

See sigprocmask(2).

Note: In multi-threaded programs, use pthread_sigmask instead.

  • parameter action

    How to modify the signal mask.

  • parameter set

    The signal set to use, or None to only retrieve the current mask.

  • returns

    The previous signal mask.