The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
signal.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
sys/types.h
>
4
5
/**
6
* @file signal.h
7
* @brief signals: kill, sigaction, masks.
8
*
9
* the numbers, flags and the kernel's sigaction layout are ABI and must
10
* match src/kernel/signal/signal.h exactly.
11
*/
12
13
typedef
unsigned
int
sigset_t
;
14
typedef
int
sig_atomic_t
;
15
16
#define SIGHUP 1
17
#define SIGINT 2
18
#define SIGQUIT 3
19
#define SIGILL 4
20
#define SIGTRAP 5
21
#define SIGABRT 6
22
#define SIGBUS 7
23
#define SIGFPE 8
24
#define SIGKILL 9
25
#define SIGUSR1 10
26
#define SIGSEGV 11
27
#define SIGUSR2 12
28
#define SIGPIPE 13
29
#define SIGALRM 14
30
#define SIGTERM 15
31
#define SIGCHLD 17
32
#define SIGCONT 18
33
#define SIGSTOP 19
34
#define SIGTSTP 20
35
#define SIGTTIN 21
36
#define SIGTTOU 22
37
#define SIGURG 23
// urgent data on a socket (ignored by default)
38
#define SIGVTALRM 26
// a virtual timer ran out (no such timers yet)
39
#define SIGPROF 27
// a profiling timer ran out (no such timers yet)
40
#define SIGWINCH 28
// the terminal's window size changed (ignored by default)
41
#define NSIG 32
42
43
typedef
void (*
sighandler_t
)(int);
44
45
#define SIG_DFL ((sighandler_t)0)
46
#define SIG_IGN ((sighandler_t)1)
47
#define SIG_ERR ((sighandler_t)-1)
48
49
// sa_flags
50
#define SA_NOCLDSTOP 0x00000001
51
#define SA_RESTORER 0x04000000
// set by the libc
52
#define SA_RESTART 0x10000000
53
#define SA_NODEFER 0x40000000
54
#define SA_RESETHAND 0x80000000
55
56
// sigprocmask how
57
#define SIG_BLOCK 0
58
#define SIG_UNBLOCK 1
59
#define SIG_SETMASK 2
60
61
struct
sigaction
62
{
63
sighandler_t
sa_handler
;
// SIG_DFL, SIG_IGN or a function
64
int
sa_flags
;
// SA_*
65
void (*
sa_restorer
)(void);
// filled in by sigaction()
66
sigset_t
sa_mask
;
// signals blocked while the handler runs
67
};
68
69
/**
70
* read and change what the process does with a signal.
71
* @return 0, or -1 (errno set; EINVAL for SIGKILL and SIGSTOP).
72
*/
73
int
sigaction
(
int
sig,
const
struct
sigaction
*act,
struct
sigaction
*oldact);
74
75
/**
76
* set a handler (with SA_RESTART, as BSD signal() does).
77
* @return the old handler, or SIG_ERR.
78
*/
79
sighandler_t
signal
(
int
sig,
sighandler_t
handler);
80
81
/**
82
* send a signal to a process (pid > 0) or every process but init (-1).
83
* @return 0, or -1 (errno set).
84
*/
85
int
kill
(
pid_t
pid,
int
sig);
86
87
/**
88
* send a signal to the calling process.
89
*/
90
int
raise
(
int
sig);
91
92
/**
93
* read and change the blocked mask.
94
*/
95
int
sigprocmask
(
int
how,
const
sigset_t
*set,
sigset_t
*oldset);
96
97
/**
98
* the signals that are blocked and pending.
99
*/
100
int
sigpending
(
sigset_t
*set);
101
102
/**
103
* wait for a signal with a temporary mask. always returns -1 with EINTR.
104
*/
105
int
sigsuspend
(
const
sigset_t
*mask);
106
107
int
sigemptyset
(
sigset_t
*set);
108
int
sigfillset
(
sigset_t
*set);
109
int
sigaddset
(
sigset_t
*set,
int
sig);
110
int
sigdelset
(
sigset_t
*set,
int
sig);
111
int
sigismember
(
const
sigset_t
*set,
int
sig);
raise
int raise(int sig)
send a signal to the calling process.
sigprocmask
int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
read and change the blocked mask.
sigdelset
int sigdelset(sigset_t *set, int sig)
sigset_t
unsigned int sigset_t
Definition
signal.h:13
kill
int kill(pid_t pid, int sig)
send a signal to a process (pid > 0) or every process but init (-1).
sigemptyset
int sigemptyset(sigset_t *set)
signal
sighandler_t signal(int sig, sighandler_t handler)
set a handler (with SA_RESTART, as BSD signal() does).
sig_atomic_t
int sig_atomic_t
Definition
signal.h:14
sigismember
int sigismember(const sigset_t *set, int sig)
sigpending
int sigpending(sigset_t *set)
the signals that are blocked and pending.
sigfillset
int sigfillset(sigset_t *set)
sighandler_t
void(*) sighandler_t(int)
Definition
signal.h:43
sigaddset
int sigaddset(sigset_t *set, int sig)
sigsuspend
int sigsuspend(const sigset_t *mask)
wait for a signal with a temporary mask.
sigaction
Definition
signal.h:62
sigaction::sa_handler
sighandler_t sa_handler
Definition
signal.h:63
sigaction::sa_restorer
void(*) sa_restorer(void)
Definition
signal.h:65
sigaction::sa_mask
sigset_t sa_mask
Definition
signal.h:66
sigaction::sa_flags
int sa_flags
Definition
signal.h:64
types.h
basic system types.
pid_t
int pid_t
Definition
types.h:16
src
libc
include
signal.h
Generated by
1.18.0