-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathsignals.theory.txt
144 lines (119 loc) · 8.01 KB
/
signals.theory.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
┏━━━━━━━━━━━━━┓
┃ SIGNALS ┃
┗━━━━━━━━━━━━━┛
┌─────────────┐
│ CONCEPT │
└─────────────┘
GOAL ==> #Simple IPC:
# - no payload except standardized names.
# - no response
#Unix only
SYNC|ASYNC ==> #Sending a signal is sync, since do not wait for response.
#Signal handler can be:
# - sync:
# - interrupt process execution
# - application-level equivalent of a CPU exception
# - e.g. FPU, segfault, abort
# - async:
# - let process handle it when it wants
# - application-level equivalent of a CPU interrupt (IRQ)
# - e.g. timer
DEFAULT HANDLER ==> #Each signal has a default handler:
# - noop (Ign)
# - terminate (Term)
# - terminate and dump to ./core (Core)
# - pause (Stop)
# - unpause (Cont)
ALLOWED HANDLER ==> #Each signal allows:
# - using the default handler (def)
# - ignoring default handler
# - using a different handler
#SIGKILL|SIGSTOP cannot be ignored|handle
#SIGCONT cannot be ignored. It can be handled but the default handler is still performed.
#SIGINT|SIGILL|SIGFPE|SIGSEGV|SIGQUIT|SIGTSTP should not be ignored
BLOCKING|MASKING ==> #A signal can be blocked: such incoming signals will then be queued until unblocked
#Paused processes block all signals
#SIGKILL|SIGSTOP|SIGCONT cannot be blocked
#Several pending signals of the same signal are queued
# - except for realtime signals, which are merged to one
#Pending signals are delivered in order
# - except for realtime signals, which are delivered by signal number order
REALTIME SIGNALS ==> #Application-specific signals
CHILD PROCESSES ==> #Inherit signals mask but not handlers
┌──────────┐
│ LIST │
└──────────┘
ANSI C89 SIGNALS ==> #
NAME NUMBER DEFAULT USAGE
SIGINT 2 Term User interrupt with CTRL-C
SIGILL 4 Core Trying to execute invalid machine instructions.
E.g. due to wrong point, buffer overlow, etc.
Similar to x64 exception #UD (invalid opcode)
SIGABRT 6 Core Abnormal exit request. E.g. used by `abort()` in C
SIGFPE 8 Core Float error.
Similar to x64 exceptions #DE (division by 0) and #MF (arithmetic overflow|underflow, wrong bits format)
SIGSEGV 11 Core Segmentation fault.
Similar to x64 exceptions #BR (buffer overflow), #SS (stack overflow|underflow), #GP (null pointer)
SIGTERM 15 Term Normal exit request.
POSIX SIGNALS ==> #
SIGHUP 1 Term Parent process stopped or communication with it stopped.
E.g. when command run in terminal and terminal was closed.
Sometimes also used to reload process
SIGQUIT 3 Core User interrupt with CTRL-\
SIGTRAP 5 Core Trace trap, used by debugger for breakpoints, watching values, etc.
Similar to x64 exceptions #DB and #BP (hardware|software breakpoints)
SIGKILL 9 Term Forced termination
SIGUSR1 10 Term User-defined signal 1
30 (Mac)
SIGUSR2 12 Term User-defined signal 2
31 (Mac)
SIGPIPE 13 Term Broken pipe (writing on a non-writable|connected|existing pipe|socket)
SIGALRM 14 Term Timer or timeout for real|user time (e.g. regardless of whether process is executing)
SIGCHLD 17 Ign A child process ended|paused|unpaused. Allows for parent process to be notified of child process exit without waiting for them
20 (Mac)
SIGCONT 18 Cont Unpause. Used by Unix commands "bg" and "fg"
19 (Mac)
SIGSTOP 19 Stop Pause
17 (Mac)
SIGTSTP 20 Stop Pause. Used by CTRL-Z or Unix command "suspend"
18 (Mac)
SIGTTIN 21 Stop Try to read stdin but there is none (i.e. background process)
SIGTTOU 22 Stop Try to read stdout|stderr but there is none (i.e. background process)
4.2 BSD SIGNALS ==> #
SIGIOT 6 Core Other name for SIGABRT
SIGBUS 7 Core Bus error due to misaligned, non-existing address or paging error
10 (Mac)
SIGURG 23 Ign Socket received out-of-band data, i.e. data not meant to be the main one, but metadata packets
16 (Mac)
SIGXCPU 24 Core Exceeded CPU time soft limit
SIGXFSZ 25 Core Exceeded file size soft limit
SIGVTALRM 26 Term Timer or timeout for virtual|process time (e.g. only when process is executing)
SIGPROF 27 Term Similar to SIGVTALRM
4.3 BSD SIGNALS ==> #
SIGWINCH 28 Ign Window size changed
SYSTEM V SIGNALS ==> #
SIGPWR 30 Term Imminent power failure
Not always available on Mac
OTHER SIGNALS ==> #
SIGBREAK 21 Term User interrupts with CTRL-BREAK, e.g. on Windows `cmd.exe`
Not always available on Mac|Linux
SIGEMT 7 Command not implemented but designed to be implemented as handler. Used to emulation.
Rarely used.
SIGSTKFLT 16 Term Stack fault (empty|overflow).
Rarely used.
SIGCLD 17 Ign Other name for SIGCHLD
Rarely used.
SIGIO 29 Term I/O is available. Often ignored.
23 (Mac)
SIGPOLL 29 Term Watched event got triggered. Used as alternative to polling.
Not always available on Mac
SIGINFO 29 Ign Ask for information about the process. Sometimes available as CTRL-T
Not always available on Linux
SIGSYS 31 Core Bad system call
12 (Mac)
SIGUNUSED 31 Term Same as SIGSYS
Not always available on Mac
REALTIME SIGNALS ==> #
SIGRTMIN 34 Term Minimum allowed realtime signal. Should be used programmatically as this constant might change
SIGRTMAX 64 Term Maximum allowed realtime signal. Should be used programmatically as this constant might change
_NSIG 65 Biggest signal number + 1