Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
b629c05a958341ddd70d4a17b52a0bbb600932cf
[simgrid.git] / tools / tesh2 / include / _signal.h
1 #ifndef __SIGNAL_H
2 #define __SIGNAL_H
3
4 #include <signal.h>
5 #include <types.h>
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 #ifdef WIN32
12
13 /* terminal line hangup                                                 */ 
14 #ifndef SIGHUP
15 #define SIGHUP          1
16 #endif 
17
18 /* interrupt program                                                    */
19 #ifndef SIGINT
20 #define SIGINT          2
21 #endif
22
23 /* quit program                                                                 */
24 #ifndef SIGQUIT
25 #define SIGQUIT         3
26 #endif
27
28 /* illegal instruction                                                  */
29 #ifndef SIGILL
30 #define SIGILL          4
31 #endif
32
33 /* trace trap                                                                   */
34 #ifndef SIGTRAP
35 #define SIGTRAP         5
36 #endif
37
38 /* abnormal termination triggered by abort call */
39 #ifndef SIGABRT
40 #define SIGABRT         6
41 #endif
42
43 /* floating point exception                                             */
44 #ifndef SIGFPE
45 #define SIGFPE          8
46 #endif
47
48 /* kill program                                                                 */
49 #ifndef SIGKILL
50 #define SIGKILL         9
51 #endif
52
53 /* bus error                                                                    */
54 #ifndef SIGBUS
55 #define SIGBUS          10
56 #endif
57
58 /* segment violation                                                    */
59 #ifndef SIGSEGV
60 #define SIGSEGV         11
61 #endif
62
63 /* non-existent system call invoked                             */
64 #ifndef SIGSYS
65 #define SIGSYS          12
66 #endif
67
68 /* write on a pipe with no reader                               */ 
69 #ifndef SIGPIPE
70 #define SIGPIPE         13
71 #endif
72
73 /* real-time timer expired                                              */
74 #ifndef SIGALRM
75 #define SIGALRM         14
76 #endif
77
78 /* software termination signal from kill                        */
79 #ifdef  SIGTERM
80 #define SIGTERM         15
81 #endif
82
83 /* urgent condition present on socket                           */
84 #ifndef SIGURG
85 #define SIGURG          16
86 #endif
87
88 /* stop (cannot be caught orignored)                            */
89 #ifndef SIGSTOP
90 #define SIGSTOP         17
91 #endif
92
93 /* stop signal generated from keyboard                          */
94 #ifndef SIGTSTP
95 #define SIGTSTP         18
96 #endif
97
98 /* continue after stop                                                          */
99 #ifndef SIGCONT
100 #define SIGCONT         19
101 #endif
102
103 /* child status has changed                                                     */ 
104 #ifndef SIGCHLD
105 #define SIGCHLD         20
106 #endif
107
108 /* background read attempted from control terminal      */
109 #ifndef SIGTTIN
110 #define SIGTTIN         21
111 #endif
112
113 /* background write attempted to control terminal       */
114 #ifndef SIGTTOU
115 #define SIGTTOU         22
116 #endif
117
118 /* I/O is possible on a descriptor see fcntl(2))        */
119 #ifndef SIGIO
120 #define SIGIO           23
121 #endif
122
123 /* cpu time limit exceeded (see setrlimit(2))           */
124 #ifndef SIGXCPU
125 #define SIGXCPU         24
126 #endif
127
128 /* file size limit exceeded (see setrlimit(2))          */
129 #ifndef SIGXFSZ
130 #define SIGXFSZ         25
131 #endif
132
133 /* virtual time alarm (see setitimer(2))                        */
134 #ifndef SIGVTALRM
135 #define SIGVTALRM       26
136 #endif
137
138 /* profiling timer alarm (see setitimer(2))                     */
139 #ifndef SIGPROF
140 #define SIGPROF         27
141 #endif
142
143 /*  window size change                                                          */
144 #ifndef SIGWINCH
145 #define SIGWINCH        28
146 #endif
147
148 /* user defined signal 1                                                        */
149 #ifndef SIGUSR1
150 #define SIGUSR1         30
151 #endif
152
153 /* user defined signal 2                                                        */
154 #ifndef SIGUSR2
155 #define SIGUSR2         31
156 #endif
157
158
159 int
160 is_an_unhandled_exception(DWORD exit_code);
161
162 /*  
163  *return a non-zero value if status was returned for a child process that terminated normally. 
164  */
165 #define WIFEXITED(__status)             !is_an_unhandled_exception((__status))
166
167 /* if the value of WIFEXITED(__status) is non-zero, this macro evaluates the value the child 
168  * process returned from main().
169  */
170 #define WEXITSTATUS(__status)   (__status)
171
172 /* return a non-zero value if status was returned for a child process that terminated due to the 
173  * receipt of a signal that was not caught 
174  */
175 #define WIFSIGNALED(__status)   is_an_unhandled_exception((__status))
176
177 /* if the value of WIFSIGNALED(__status) is non-zero, this macro evaluates to the number of the 
178  * signal that caused the termination of the child process.
179  */
180 #define WTERMSIG(__status)              (__status)
181
182 #endif /* WIN32 */
183
184
185 #ifdef WIN32
186 const char* 
187 signal_name(DWORD got, char* expected);
188 #else
189 const char* 
190 signal_name(unsigned int got, char *expected);
191 #endif
192
193 #ifdef __cplusplus
194 }
195 #endif
196
197 #endif /* !__SIGNAL_H */