|
ginnOS
The reference: libc, the libraries and the kernel
|
#include "common/stdint.h"Go to the source code of this file.
Data Structures | |
| struct | ksigaction_t |
| what a process does with one signal (ABI: the sigaction syscall copies it to and from user space in this layout). More... | |
| struct | signal_state_t |
| the signal state of a process (inside process_t). More... | |
| struct | signal_handlers |
| what a process does with each signal. More... | |
Macros | |
| #define | SIGHUP 1 |
| signal numbers. | |
| #define | SIGINT 2 |
| #define | SIGQUIT 3 |
| #define | SIGILL 4 |
| #define | SIGTRAP 5 |
| #define | SIGABRT 6 |
| #define | SIGBUS 7 |
| #define | SIGFPE 8 |
| #define | SIGKILL 9 |
| #define | SIGUSR1 10 |
| #define | SIGSEGV 11 |
| #define | SIGUSR2 12 |
| #define | SIGPIPE 13 |
| #define | SIGALRM 14 |
| #define | SIGTERM 15 |
| #define | SIGCHLD 17 |
| #define | SIGCONT 18 |
| #define | SIGSTOP 19 |
| #define | SIGTSTP 20 |
| #define | SIGTTIN 21 |
| #define | SIGTTOU 22 |
| #define | SIGURG 23 |
| #define | SIGVTALRM 26 |
| #define | SIGPROF 27 |
| #define | SIGWINCH 28 |
| #define | NSIG 32 |
| #define | SIG_BIT(sig) |
| #define | SIG_UNBLOCKABLE (SIG_BIT(SIGKILL) | SIG_BIT(SIGSTOP)) |
| #define | SIG_DFL 0 |
| #define | SIG_IGN 1 |
| #define | SA_NOCLDSTOP 0x00000001 |
| #define | SA_RESTORER 0x04000000 |
| #define | SA_RESTART 0x10000000 |
| #define | SA_NODEFER 0x40000000 |
| #define | SA_RESETHAND 0x80000000 |
| #define | SIG_BLOCK 0 |
| #define | SIG_UNBLOCK 1 |
| #define | SIG_SETMASK 2 |
Typedefs | |
| typedef struct signal_handlers | signal_handlers_t |
| what a process does with each signal. | |
Functions | |
| signal_handlers_t * | signal_handlers_create (void) |
| make a set of handlers, all SIG_DFL, with one user. | |
| signal_handlers_t * | signal_handlers_get (signal_handlers_t *handlers) |
| add a user to a set of handlers (a new thread that shares it). | |
| void | signal_handlers_put (signal_handlers_t *handlers) |
| remove a user from a set of handlers; the last user frees it. | |
| void | signal_send (struct process *proc, int sig) |
| send a signal to one thread. | |
| void | signal_send_process (struct process *proc, int sig) |
| send a signal to a process (a thread group): one of its threads takes it (signal_send), one that does not block it if there is one. | |
| int | signal_send_group (uint32_t pgid, int sig) |
| send a signal to every process of a process group. | |
| void | signal_force (struct process *proc, int sig) |
| send a signal caused by the process's own instruction (a fault). | |
| bool | signal_pending (const struct process *proc) |
| true if a signal waits that the process does not block. | |
| void | signal_deliver (struct registers *regs) |
| act on pending signals before returning to user mode: run the default action, or set up the user handler's frame. | |
| void | signal_fork (struct process *child, const struct process *parent) |
| the signal state of a forked child: the parent's mask, no pending signals. | |
| void | signal_exec (struct process *proc) |
| the signal state after execve: handlers go back to SIG_DFL (ignored signals stay ignored); the mask and pending signals stay. | |
| uint32_t | signal_state_lock (void) |
| take the lock of the signal state of all processes, with interrupts masked. | |
| void | signal_state_unlock (uint32_t flags) |
| release the lock that signal_state_lock() took. | |
| void | signal_init (void) |
| set up signal handling. | |
| void | signal_alarm_tick (uint64_t now) |
| send SIGALRM to processes whose alarm is due. | |
| #define SIGHUP 1 |
signal numbers.
they are ABI: the same numbers are in the libc's <signal.h>, and a process killed by a signal reports its number in its wait status (wait_status.h).
| #define SIGINT 2 |
| #define SIGQUIT 3 |
| #define SIGILL 4 |
| #define SIGTRAP 5 |
| #define SIGABRT 6 |
| #define SIGBUS 7 |
| #define SIGFPE 8 |
| #define SIGKILL 9 |
| #define SIGUSR1 10 |
| #define SIGSEGV 11 |
| #define SIGUSR2 12 |
| #define SIGPIPE 13 |
| #define SIGALRM 14 |
| #define SIGTERM 15 |
| #define SIGCHLD 17 |
| #define SIGCONT 18 |
| #define SIGSTOP 19 |
| #define SIGTSTP 20 |
| #define SIGTTIN 21 |
| #define SIGTTOU 22 |
| #define SIGURG 23 |
| #define SIGVTALRM 26 |
| #define SIGPROF 27 |
| #define SIGWINCH 28 |
| #define NSIG 32 |
| #define SIG_BIT | ( | sig | ) |
| #define SIG_DFL 0 |
| #define SIG_IGN 1 |
| #define SA_NOCLDSTOP 0x00000001 |
| #define SA_RESTORER 0x04000000 |
| #define SA_RESTART 0x10000000 |
| #define SA_NODEFER 0x40000000 |
| #define SA_RESETHAND 0x80000000 |
| #define SIG_BLOCK 0 |
| #define SIG_UNBLOCK 1 |
| #define SIG_SETMASK 2 |
| typedef struct signal_handlers signal_handlers_t |
what a process does with each signal.
the threads of a process use one together; it is freed when the last of them lets it go.
| signal_handlers_t * signal_handlers_create | ( | void | ) |
make a set of handlers, all SIG_DFL, with one user.
| signal_handlers_t * signal_handlers_get | ( | signal_handlers_t * | handlers | ) |
add a user to a set of handlers (a new thread that shares it).
| void signal_handlers_put | ( | signal_handlers_t * | handlers | ) |
remove a user from a set of handlers; the last user frees it.
| handlers | the set, or NULL (nothing is done). |
| void signal_send | ( | struct process * | proc, |
| int | sig ) |
send a signal to one thread.
a signal the process ignores is dropped; a deliverable one wakes the process from an interruptible sleep. SIGCONT continues a stopped process, SIGKILL wakes one. safe in any context.
| proc | the process. |
| sig | the signal (1 to NSIG - 1). |
| void signal_send_process | ( | struct process * | proc, |
| int | sig ) |
send a signal to a process (a thread group): one of its threads takes it (signal_send), one that does not block it if there is one.
SIGCONT goes to every thread.
| proc | any thread of the process, or NULL (nothing is done). |
| sig | the signal. |
| int signal_send_group | ( | uint32_t | pgid, |
| int | sig ) |
send a signal to every process of a process group.
| pgid | the group. |
| sig | the signal. |
| void signal_force | ( | struct process * | proc, |
| int | sig ) |
send a signal caused by the process's own instruction (a fault).
it is delivered even if blocked or ignored: blocked or ignored, it kills.
| proc | the process. |
| sig | the signal. |
true if a signal waits that the process does not block.
a sleeping syscall that sees this gives up its wait (EINTR or a restart).
| proc | the process (NULL: false). |
| void signal_deliver | ( | struct registers * | regs | ) |
act on pending signals before returning to user mode: run the default action, or set up the user handler's frame.
also turns an interrupted syscall's -ERESTARTSYS into EINTR or a restart. called at the end of every interrupt and syscall that came from user mode.
| regs | the user registers about to be restored. |
the signal state of a forked child: the parent's mask, no pending signals.
the child's handlers (its own set) are copied from the parent's.
| void signal_exec | ( | struct process * | proc | ) |
the signal state after execve: handlers go back to SIG_DFL (ignored signals stay ignored); the mask and pending signals stay.
| uint32_t signal_state_lock | ( | void | ) |
take the lock of the signal state of all processes, with interrupts masked.
it also guards the exit and exec state of each thread group (group_exiting, group_status, exec_thread) and the waitpid reports, as the signal_struct lock does in Linux. it nests outside the process table lock and sched_lock.
| void signal_state_unlock | ( | uint32_t | flags | ) |
release the lock that signal_state_lock() took.
| flags | the value from signal_state_lock(). |
| void signal_init | ( | void | ) |
set up signal handling.
call once at boot.
| void signal_alarm_tick | ( | uint64_t | now | ) |
send SIGALRM to processes whose alarm is due.
called from the timer interrupt.
| now | the current tick. |