|
x-engine-c v0.2.31
The C engine for x-lang
|
Signal handling primitives: SIGINT, and any signal recorded. More...
Macros | |
| #define | _GNU_SOURCE |
Functions | |
| static void | x_sigint_handler (int sig) |
| static x_obj_t * | x_prim_sigint_install (x_obj_t *p_base, x_obj_t *p_args) |
| static x_obj_t * | x_prim_sigint_restore (x_obj_t *p_base, x_obj_t *p_args) |
| static void | x_signal_record (int sig) |
| static int | x_signal_valid (x_int_t sig) |
| static x_obj_t * | x_prim_signal_catch (x_obj_t *p_base, x_obj_t *p_args) |
| static x_obj_t * | x_prim_signal_take (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_prim_signal_register (x_obj_t *p_base, x_obj_t *p_args) |
Variables | |
| static x_satom_t | x_sigint_flag = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .i = 0 }) |
| static volatile sig_atomic_t | x_signal_arrived [NSIG] |
Signal handling primitives: SIGINT, and any signal recorded.
signal catch and signal take record any other signal's arrival in a static flag and report it; what an arrival means is left to x-lang.
A static atom's .i field is the SIGINT flag (unavoidable: POSIX handlers receive only the signal number, not an application context). Its pointer is published into the base (x_eval_field_sigint) so x_eval can poll it via p_base rather than naming this module's global. Bound as sigint-flag so x-lang can read/clear it with first-int / set-first-int!.
This is the signal-support module: it is compiled and linked only when X_SIGNAL is enabled (the Makefile drops it from the build otherwise, and the x-lang library falls back to inert no-ops).
| #define _GNU_SOURCE |
Install the SIGINT handler. x-lang: (sigint-install)
Restore default SIGINT handling. x-lang: (sigint-restore)
Catch a signal: from now on its arrival is recorded, for signal-take to report, and nothing else is done. What the arrival means is the caller's to decide. x-lang: (signal catch sig)
| p_base | Base (execution context). |
| p_args | The signal number. |
Register signal primitives and bind sigint-flag.
Whether a caught signal has arrived since the last take, clearing the record. Two arrivals between takes are one, as the kernel's own pending set has them. x-lang: (signal take sig)
| p_base | Base (execution context). |
| p_args | The signal number. |
|
static |
|
static |
|
static |
Whether sig names a signal this module can record.
|
static |
Static atom whose .i field is the SIGINT flag. Kept in static (non-heap) storage so the handler can write it without risk of a GC relocation moving it mid-store.
|
static |
One flag a signal number: set by the handler when that signal arrives, cleared by signal-take. Static, so the handler writes no heap object.