#pragma once #include #include #define SIG_DFL 0 #define SIG_IGN -1 typedef enum { SIGABRT, // Abort signal from abort(3) SIGALRM, // Timer signal from alarm(2) SIGBUS, // Bus error (bad memory access) SIGCHLD, // Child stopped or terminated SIGCLD, // A synonym for SIGCHLD SIGCONT, // Continue if stopped SIGEMT, // Emulator trap SIGFPE, // Floating-point exception SIGHUP, // Hangup detected on controlling terminal or death of // controlling process SIGILL, // Illegal Instruction SIGINFO, // A synonym for SIGPWR SIGINT, // Interrupt from keyboard SIGIO, // I/O now possible (4.2BSD) SIGIOT, // IOT trap. A synonym for SIGABRT SIGKILL, // Kill signal SIGLOST, // File lock lost (unused) SIGPIPE, // Broken pipe: write to pipe with no readers; see pipe(7) SIGPOLL, // Pollable event (Sys V); synonym for SIGIO SIGPROF, // Profiling timer expired SIGPWR, // Power failure (System V) SIGQUIT, // Quit from keyboard SIGSEGV, // Invalid memory reference SIGSTKFLT, // Stack fault on coprocessor (unused) SIGSTOP, // Stop process SIGTSTP, // Stop typed at terminal SIGSYS, // Bad system call (SVr4); see also seccomp(2) SIGTERM, // Termination signal SIGTRAP, // Trace/breakpoint trap SIGTTIN, // Terminal input for background process SIGTTOU, // Terminal output for background process SIGUNUSED, // Synonymous with SIGSYS SIGURG, // Urgent condition on socket (4.2BSD) SIGUSR1, // User-defined signal 1 SIGUSR2, // User-defined signal 2 SIGVTALRM, // Virtual alarm clock (4.2BSD) SIGXCPU, // CPU time limit exceeded (4.2BSD); see setrlimit(2) SIGXFSZ, // File size limit exceeded (4.2BSD); see setrlimit(2) SIGWINCH, // Window resize signal (4.3BSD, Sun) SIG_INT, // Interrupt from keyboard LAST } SIGNAL_CODE; typedef void (*signal_handler_t)(int); void signal(SIGNAL_CODE sig_num, void *handler); void kill(int pid, SIGNAL_CODE sig_num); void exec_signal_pending(void); struct signal_data { void *handlers[LAST]; uint32_t pending; };