← all modules
module

stdlib::signal

defined in C:\Users\bye45\.glide\bin/src/stdlib/signal.glide

Internal helper called from the c_raw reader thread to push signum onto

enum enum Signal
fn fn _signal_push(c: chan<Signal>, n: int)

Internal helper called from the c_raw reader thread to push signum onto the typed chan<Signal>. Defined Glide-side so c_raw doesn't need Signal's private struct layout to construct the value.

fn fn signal_chan(s: Signal) -> chan<Signal>

Subscribe to s. Each occurrence pushes the same Signal onto the returned channel. Idempotent — repeated calls for the same signal return the same chan. Buffer = 64 (delivered-faster-than-consumed signals beyond that are dropped — typical for shutdown signals which deliver once).

glide
let intr: chan<Signal> = signal_chan(Signal::Int);
loop {
    select! {
        sig = intr.recv() => {
            println!("got", sig.name());
            break;
        }
    }
}
fn fn signal_default(s: Signal) -> !void

Restore the default OS handler for s. The chan returned by a previous signal_chan(s) stops receiving.

glide
signal_default(Signal::Int);   // Ctrl+C now terminates again
fn fn signal_ignore(s: Signal) -> !void

Discard s (no chan, no default behavior). Useful for SIGPIPE on servers that handle disconnect at the read/write level.

glide
signal_ignore(Signal::Pipe);   // writes to closed sockets won't kill us
fn fn signal_raise(s: Signal) -> !void

Raise s against the current process. If a subscription is active, the signal is pushed directly to the chan (cross-platform reliable, no OS round-trip). Otherwise falls back to raise(sig) (POSIX) or GenerateConsoleCtrlEvent (Windows) — Windows can only raise SIGINT and SIGTERM at OS level, but in-process raise via subscription works for any signum.

glide
Useful in tests: subscribe + raise to drive a select! arm.
let usr1: chan<Signal> = signal_chan(Signal::Usr1);
signal_raise(Signal::Usr1);
let s: Signal = usr1.recv();   // gets Signal::Usr1