Revision 8d963e6a os-posix.c
b/os-posix.c | ||
---|---|---|
26 | 26 |
#include <unistd.h> |
27 | 27 |
#include <fcntl.h> |
28 | 28 |
#include <signal.h> |
29 |
#include <sys/types.h> |
|
30 |
#include <sys/wait.h> |
|
29 | 31 |
|
30 | 32 |
/* Needed early for CONFIG_BSD etc. */ |
31 | 33 |
#include "config-host.h" |
... | ... | |
39 | 41 |
act.sa_handler = SIG_IGN; |
40 | 42 |
sigaction(SIGPIPE, &act, NULL); |
41 | 43 |
} |
44 |
|
|
45 |
static void termsig_handler(int signal) |
|
46 |
{ |
|
47 |
qemu_system_shutdown_request(); |
|
48 |
} |
|
49 |
|
|
50 |
static void sigchld_handler(int signal) |
|
51 |
{ |
|
52 |
waitpid(-1, NULL, WNOHANG); |
|
53 |
} |
|
54 |
|
|
55 |
void os_setup_signal_handling(void) |
|
56 |
{ |
|
57 |
struct sigaction act; |
|
58 |
|
|
59 |
memset(&act, 0, sizeof(act)); |
|
60 |
act.sa_handler = termsig_handler; |
|
61 |
sigaction(SIGINT, &act, NULL); |
|
62 |
sigaction(SIGHUP, &act, NULL); |
|
63 |
sigaction(SIGTERM, &act, NULL); |
|
64 |
|
|
65 |
act.sa_handler = sigchld_handler; |
|
66 |
act.sa_flags = SA_NOCLDSTOP; |
|
67 |
sigaction(SIGCHLD, &act, NULL); |
|
68 |
} |
Also available in: Unified diff