signals/core

sourcesignals/core.sx

MAX_LISTENERS

pub val MAX_LISTENERS = 32

Number of listeners that can be registered at once.

MAX_SIGNALS

pub val MAX_SIGNALS = 128

Highest signal number accepted by the numeric API.

Signal

pub enum Signal = { Hangup, Interrupt, Quit, IllegalInstruction, Trap, Abort, Break, BusError, FloatingPointException, Kill, User1, SegmentationViolation, User2, Pipe, Alarm, Terminate, Child, Continue, Stop, StopTerminal, BackgroundRead, BackgroundWrite, Urgent, CpuTimeExceeded, FileSizeExceeded, VirtualTimer, ProfilingTimer, WindowChange, Io, Power, System }

Signals that can be intercepted.

Some entries only exist on certain platforms. number returns -1 and on reports SignalError.Unsupported when a signal is not available.

Variants

  • Hangup
  • Interrupt
  • Quit
  • IllegalInstruction
  • Trap
  • Abort
  • Break
  • BusError
  • FloatingPointException
  • Kill
  • User1
  • SegmentationViolation
  • User2
  • Pipe
  • Alarm
  • Terminate
  • Child
  • Continue
  • Stop
  • StopTerminal
  • BackgroundRead
  • BackgroundWrite
  • Urgent
  • CpuTimeExceeded
  • FileSizeExceeded
  • VirtualTimer
  • ProfilingTimer
  • WindowChange
  • Io
  • Power
  • System

SignalError

pub enum SignalError = { InvalidSignal, Unsupported, CannotCatch, TableFull, InvalidListener, InstallFailed }

Errors reported while installing or removing signal listeners.

Variants

  • InvalidSignal
  • Unsupported
  • CannotCatch
  • TableFull
  • InvalidListener
  • InstallFailed

listener_signal_slot

private
fn listener_signal_slot(index: i64) mut ref i32 = trust { ... }

listener_callback_slot

private
fn listener_callback_slot(index: i64) mut ref usize = trust { ... }

previous_slot

private
fn previous_slot(signum: i32) mut ref usize = trust { ... }

installed_slot

private
fn installed_slot(signum: i32) mut ref usize = trust { ... }

linux_number

private
fn linux_number(sig: Signal) i32

bsd_number

private
fn bsd_number(sig: Signal) i32

windows_number

private
fn windows_number(sig: Signal) i32

number

pub fn number(sig: Signal) i32

Return the platform signal number for sig, or -1 when the signal does not exist on the current platform.

name

pub fn name(sig: Signal) ref u8

Return the conventional name of sig (for example "SIGINT").

dispatch

private
fn dispatch(signum: i32) void = trust { ... }

install

private
fn install(signum: i32) result[void, SignalError] = trust { ... }

on_number

pub fn on_number(signum: i32, listener: fn(i32) void) result[void, SignalError] = trust { ... }

Register listener for a numeric signal.

Multiple listeners may be registered for the same signal; they run in the order they were added. Returns an error when the signal is invalid, cannot be caught, or the listener table is full.

on

pub fn on(sig: Signal, listener: fn(i32) void) result[void, SignalError] = trust { ... }

Register listener for sig.

off_number

pub fn off_number(signum: i32) void = trust { ... }

Remove every listener registered for a numeric signal and restore the handler that was installed before the first listener was added.

off

pub fn off(sig: Signal) void = trust { ... }

Remove every listener registered for sig.

clear

pub fn clear() void = trust { ... }

Remove every listener and restore all previous signal handlers.

raise_number

pub fn raise_number(signum: i32) i32 = trust { ... }

Send a numeric signal to the current process.

raise_signal

pub fn raise_signal(sig: Signal) i32 = trust { ... }

Send sig to the current process.

test_listener

private
fn test_listener(sig: i32) void