miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Loading...
Searching...
No Matches
signal.h File Reference
#include <miniOS/types.h>
Include dependency graph for signal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mini_sigaction

Macros

#define SIGHUP   1 /* hangup */
#define SIGINT   2 /* interrupt (Ctrl-C) */
#define SIGQUIT   3 /* quit (Ctrl-\‍) */
#define SIGILL   4 /* illegal instruction */
#define SIGABRT   6 /* abort */
#define SIGTRAP   5 /* breakpoint/single-step trap (ptrace) */
#define SIGFPE   8 /* floating-point exception */
#define SIGKILL   9 /* unconditional termination; cannot be caught or ignored */
#define SIGSEGV   11 /* segmentation fault */
#define SIGPIPE   13 /* broken pipe */
#define SIGALRM   14 /* alarm clock (ITIMER_REAL expiry) */
#define SIGTERM   15 /* termination request; default action terminates process */
#define SIGCHLD   17 /* sent to parent when a child exits or stops (Linux ABI) */
#define SIGCONT   18 /* continue if stopped */
#define SIGSTOP   19 /* stop (cannot be caught or ignored) */
#define SIGTSTP   20 /* terminal stop (Ctrl-Z) */
#define SIG_DFL   ((sighandler_t)0) /* default signal action */
#define SIG_IGN   ((sighandler_t)1) /* ignore signal */
#define MINIOS_SA_NOCLDWAIT   0x00000002U /* do not produce zombies; skip SIGCHLD delivery */
#define MINIOS_SA_RESTART   0x10000000U /* restart interrupted syscall on signal return */
#define MINIOS_SA_RESETHAND   0x80000000U /* reset to SIG_DFL on delivery */

Typedefs

typedef void(* sighandler_t) (int signum)
typedef uint32_t minisigset_t
typedef struct mini_sigaction mini_sigaction_t

Functions

void signal_dispatch (void)
void ring3_invoke_handler (int sig, sighandler_t handler)

Macro Definition Documentation

◆ MINIOS_SA_NOCLDWAIT

#define MINIOS_SA_NOCLDWAIT   0x00000002U /* do not produce zombies; skip SIGCHLD delivery */

◆ MINIOS_SA_RESETHAND

#define MINIOS_SA_RESETHAND   0x80000000U /* reset to SIG_DFL on delivery */

◆ MINIOS_SA_RESTART

#define MINIOS_SA_RESTART   0x10000000U /* restart interrupted syscall on signal return */

◆ SIG_DFL

#define SIG_DFL   ((sighandler_t)0) /* default signal action */

◆ SIG_IGN

#define SIG_IGN   ((sighandler_t)1) /* ignore signal */

◆ SIGABRT

#define SIGABRT   6 /* abort */

◆ SIGALRM

#define SIGALRM   14 /* alarm clock (ITIMER_REAL expiry) */

◆ SIGCHLD

#define SIGCHLD   17 /* sent to parent when a child exits or stops (Linux ABI) */

◆ SIGCONT

#define SIGCONT   18 /* continue if stopped */

◆ SIGFPE

#define SIGFPE   8 /* floating-point exception */

◆ SIGHUP

#define SIGHUP   1 /* hangup */

◆ SIGILL

#define SIGILL   4 /* illegal instruction */

◆ SIGINT

#define SIGINT   2 /* interrupt (Ctrl-C) */

◆ SIGKILL

#define SIGKILL   9 /* unconditional termination; cannot be caught or ignored */

◆ SIGPIPE

#define SIGPIPE   13 /* broken pipe */

◆ SIGQUIT

#define SIGQUIT   3 /* quit (Ctrl-\‍) */

◆ SIGSEGV

#define SIGSEGV   11 /* segmentation fault */

◆ SIGSTOP

#define SIGSTOP   19 /* stop (cannot be caught or ignored) */

◆ SIGTERM

#define SIGTERM   15 /* termination request; default action terminates process */

◆ SIGTRAP

#define SIGTRAP   5 /* breakpoint/single-step trap (ptrace) */

◆ SIGTSTP

#define SIGTSTP   20 /* terminal stop (Ctrl-Z) */

Typedef Documentation

◆ mini_sigaction_t

mini_sigaction_t — per-signal disposition record.

Stored in struct thread::signal_actions[1..31]. sa_flags holds MINIOS_SA_RESTART and other SA_* flags. sa_mask is reserved (zero) — miniOS does not block signals during handlers yet.

◆ minisigset_t

◆ sighandler_t

typedef void(* sighandler_t) (int signum)

Function Documentation

◆ ring3_invoke_handler()

void ring3_invoke_handler ( int sig,
sighandler_t handler )

ring3_invoke_handler() - Set up user stack to invoke a signal handler. @sig: Signal number passed as first argument to handler (RDI per SysV ABI). @handler: User-mode function pointer to invoke.

Modifies the current thread's saved_user_rip to point to @handler and adjusts saved_user_rsp to push the signal number onto the user stack. SYSRET then jumps directly into the handler. Full trampoline (return path via SYS_sigreturn).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ signal_dispatch()

void signal_dispatch ( void )

signal_dispatch() - Deliver all pending signals before returning to userspace.

Called from syscall.asm immediately before SYSRET. Scans the current thread's pending_signals bitmask (bits 1-31). For SIGKILL and SIGTERM calls sched_exit_current(128 + signum). For other signals invokes the registered handler via ring3_invoke_handler() if a non-default handler is registered, otherwise clears the pending bit and continues.

Context: Called with interrupts disabled (CLI before SYSRET path). Does not return if SIGKILL or SIGTERM is pending.

Here is the call graph for this function: