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
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.
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).
let intr: chan<Signal> = signal_chan(Signal::Int);
loop {
select! {
sig = intr.recv() => {
println!("got", sig.name());
break;
}
}
}
Restore the default OS handler for s. The chan returned by a previous signal_chan(s) stops receiving.
signal_default(Signal::Int); // Ctrl+C now terminates again
Discard s (no chan, no default behavior). Useful for SIGPIPE on servers that handle disconnect at the read/write level.
signal_ignore(Signal::Pipe); // writes to closed sockets won't kill us
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.
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