152
|
1 /* Example of a bad call within a signal handler with replacement
|
|
2 alternative. 'handler' calls 'exit', and 'exit' is not allowed
|
|
3 from a signal handler. But '_exit' is allowed. */
|
|
4
|
|
5 #include <signal.h>
|
|
6 #include <stdlib.h>
|
|
7
|
|
8 extern void body_of_program(void);
|
|
9
|
|
10 static void handler(int signum)
|
|
11 {
|
|
12 exit(1); /* { dg-warning "call to 'exit' from within signal handler" "warning" } */
|
|
13 /* { dg-message "note: '_exit' is a possible signal-safe alternative for 'exit'" "replacement note" { target *-*-* } .-1 } */
|
|
14 }
|
|
15
|
|
16 int main(int argc, const char *argv)
|
|
17 {
|
|
18 signal(SIGINT, handler); /* { dg-message "registering 'handler' as signal handler" } */
|
|
19
|
|
20 body_of_program();
|
|
21
|
|
22 return 0;
|
|
23 }
|