-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSignalHandling
More file actions
163 lines (163 loc) · 4.54 KB
/
Copy pathSignalHandling
File metadata and controls
163 lines (163 loc) · 4.54 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/* -*- c++ -*- */
///////////////////////////////////////////
// SignalHandling
// -------------------------------------
// file : SignalHandling
// author : Ben Kietzman
// begin : 2010-03-03
// copyright : Ben Kietzman
// email : ben@kietzman.org
///////////////////////////////////////////
/*! \file SignalHandling
* \brief SignalHandling Functions
*/
#ifndef _COMMON_SIGNALHANDLING_
#define _COMMON_SIGNALHANDLING_
// {{{ includes
#include <csignal>
#include <cstring>
#include <string>
using namespace std;
// }}}
extern "C++"
{
namespace common
{
// {{{ defines
#ifndef SIGHUP
#define SIGHUP 1 /* hangup */
#endif
#ifndef SIGINT
#define SIGINT 2 /* interrupt (rubout) */
#endif
#ifndef SIGQUIT
#define SIGQUIT 3 /* quit (ASCII FS) */
#endif
#ifndef SIGILL
#define SIGILL 4 /* illegal instruction (not reset when caught) */
#endif
#ifndef SIGTRAP
#define SIGTRAP 5 /* trace trap (not reset when caught) */
#endif
#ifndef SIGIOT
#define SIGIOT 6 /* IOT instruction */
#endif
#ifndef SIGABRT
#define SIGABRT 6 /* used by abort, replace SIGIOT in the future */
#endif
#ifndef SIGFPE
#define SIGFPE 8 /* floating point exception */
#endif
#ifndef SIGKILL
#define SIGKILL 9 /* kill (cannot be caught or ignored) */
#endif
#ifndef SIGBUS
#define SIGBUS 10 /* bus error */
#endif
#ifndef SIGSEGV
#define SIGSEGV 11 /* segmentation violation */
#endif
#ifndef SIGSYS
#define SIGSYS 12 /* bad argument to system call */
#endif
#ifndef SIGPIPE
#define SIGPIPE 13 /* write on a pipe with no one to read it */
#endif
#ifndef SIGALRM
#define SIGALRM 14 /* alarm clock */
#endif
#ifndef SIGTERM
#define SIGTERM 15 /* software termination signal from kill */
#endif
#ifndef SIGCLD
#define SIGCLD 18 /* child status change */
#endif
#ifndef SIGCHLD
#define SIGCHLD 18 /* child status change alias (POSIX) */
#endif
#ifndef COMMON_MACOS
#ifndef SIGPWR
#define SIGPWR 19 /* power-fail restart */
#endif
#endif
#ifndef SIGWINCH
#define SIGWINCH 20 /* window size change */
#endif
#ifndef SIGURG
#define SIGURG 21 /* urgent socket condition */
#endif
#ifndef COMMON_MACOS
#ifndef SIGPOLL
#define SIGPOLL 22 /* pollable event occured */
#endif
#endif
#ifndef SIGIO
#define SIGIO SIGPOLL /* socket I/O possible (SIGPOLL alias) */
#endif
#ifndef SIGSTOP
#define SIGSTOP 23 /* stop (cannot be caught or ignored) */
#endif
#ifndef SIGTSTP
#define SIGTSTP 24 /* user stop requested from tty */
#endif
#ifndef SIGCONT
#define SIGCONT 25 /* stopped process has been continued */
#endif
#ifndef SIGTTIN
#define SIGTTIN 26 /* background tty read attempted */
#endif
#ifndef SIGTTOU
#define SIGTTOU 27 /* background tty write attempted */
#endif
#ifndef SIGVTALRM
#define SIGVTALRM 28 /* virtual timer expired */
#endif
#ifndef SIGPROF
#define SIGPROF 29 /* profiling timer expired */
#endif
#ifndef SIGXCPU
#define SIGXCPU 30 /* exceeded cpu limit */
#endif
#ifndef SIGXFSZ
#define SIGXFSZ 31 /* exceeded file size limit */
#endif
#ifndef SIGWAITING
#define SIGWAITING 32 /* process's lwps are blocked */
#endif
#ifndef SIGLWP
#define SIGLWP 33 /* special signal used by thread library */
#endif
#ifndef SIGFREEZE
#define SIGFREEZE 34 /* special signal used by CPR */
#endif
#ifndef SIGTHAW
#define SIGTHAW 35 /* special signal used by CPR */
#endif
#ifndef SIGCANCEL
#define SIGCANCEL 36 /* thread cancellation signal used by libthread */
#endif
#ifndef SIGLOST
#define SIGLOST 37 /* resource lost (eg, record-lock lost) */
#endif
// }}}
// {{{ prototypes
//! Designates the given function to handle any signals that are caught.
/*!
* \param function - Contain the address to the function that will catch and handle signals.
*/
void sethandles(void (*function)(int));
//! Translates the given signal id to a string interpretation.
/*!
* \param strSignal - Stores the string version of the signal.
* \param nSignal - The given stignal id.
*/
string sigstring(string &strSignal, int nSignal);
//! Sets the given signal to be ignored.
/*!
* \param nSignal - The given signal to be ignored.
*/
void sigdummy(int nSignal);
// }}}
}
}
#endif