x-engine-c v0.2.13
The C engine for x-lang
Loading...
Searching...
No Matches
signal.c File Reference

SIGINT signal handling primitives. More...

#include "x-prim.h"
#include "x-eval.h"
#include <signal.h>

Macros

#define _GNU_SOURCE
 

Functions

static void x_sigint_handler (int sig)
 
static x_obj_tx_prim_sigint_install (x_obj_t *p_base, x_obj_t *p_args)
 
static x_obj_tx_prim_sigint_restore (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_tx_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 })
 

Detailed Description

SIGINT signal handling primitives.

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).

Author
Jon Ruttan (jonru.nosp@m.ttan.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Function Documentation

◆ x_prim_sigint_install()

static x_obj_t * x_prim_sigint_install ( x_obj_t p_base,
x_obj_t p_args 
)
static

Install the SIGINT handler. x-lang: (sigint-install)

◆ x_prim_sigint_restore()

static x_obj_t * x_prim_sigint_restore ( x_obj_t p_base,
x_obj_t p_args 
)
static

Restore default SIGINT handling. x-lang: (sigint-restore)

◆ x_prim_signal_register()

x_obj_t * x_prim_signal_register ( x_obj_t p_base,
x_obj_t p_args 
)

Register signal primitives and bind sigint-flag.

◆ x_sigint_handler()

static void x_sigint_handler ( int  sig)
static

Variable Documentation

◆ x_sigint_flag

x_satom_t x_sigint_flag = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .i = 0 })
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.