]> Git Repo - qemu.git/commitdiff
Move main signal handler setup to os specificfiles.
authorJes Sorensen <[email protected]>
Thu, 10 Jun 2010 09:42:22 +0000 (11:42 +0200)
committerBlue Swirl <[email protected]>
Sat, 12 Jun 2010 05:49:14 +0000 (08:49 +0300)
Move main signal handler setup to os specific files.

Signed-off-by: Jes Sorensen <[email protected]>
Acked-by: Juan Quintela <[email protected]>
Acked-by: Richard Henderson <[email protected]>
Signed-off-by: Blue Swirl <[email protected]>
os-posix.c
qemu-os-posix.h
qemu-os-win32.h
vl.c

index 948f662e910839b98537e47ca8964fc41851a211..01dbec2e36e6b76f240075a33acc26db8ba1faf8 100644 (file)
@@ -26,6 +26,8 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 
 /* Needed early for CONFIG_BSD etc. */
 #include "config-host.h"
@@ -39,3 +41,28 @@ void os_setup_early_signal_handling(void)
     act.sa_handler = SIG_IGN;
     sigaction(SIGPIPE, &act, NULL);
 }
+
+static void termsig_handler(int signal)
+{
+    qemu_system_shutdown_request();
+}
+
+static void sigchld_handler(int signal)
+{
+    waitpid(-1, NULL, WNOHANG);
+}
+
+void os_setup_signal_handling(void)
+{
+    struct sigaction act;
+
+    memset(&act, 0, sizeof(act));
+    act.sa_handler = termsig_handler;
+    sigaction(SIGINT,  &act, NULL);
+    sigaction(SIGHUP,  &act, NULL);
+    sigaction(SIGTERM, &act, NULL);
+
+    act.sa_handler = sigchld_handler;
+    act.sa_flags = SA_NOCLDSTOP;
+    sigaction(SIGCHLD, &act, NULL);
+}
index 96d1036b47135707c67e2d3c22962b36a4c7bbf8..ff5adb1b2b5bfe5a8e5b52f595f24172b936c7a0 100644 (file)
@@ -30,4 +30,6 @@ static inline void os_host_main_loop_wait(int *timeout)
 {
 }
 
+void os_setup_signal_handling(void);
+
 #endif
index 4d1cac852b2534413eea5122542177f26b7aed59..e7e2ee3abfe476f7418dc2e10fc5f54ce17aec21 100644 (file)
@@ -41,4 +41,7 @@ int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
 void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
 
 void os_host_main_loop_wait(int *timeout);
+
+static inline void os_setup_signal_handling(void) {}
+
 #endif
diff --git a/vl.c b/vl.c
index 4fcedbfeb71995f816e8af66c06940fd1910eaec..807da7b97269253c2cc197d1e82db4f41e449cab 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -1986,35 +1986,6 @@ static int balloon_parse(const char *arg)
     return -1;
 }
 
-#ifndef _WIN32
-
-static void termsig_handler(int signal)
-{
-    qemu_system_shutdown_request();
-}
-
-static void sigchld_handler(int signal)
-{
-    waitpid(-1, NULL, WNOHANG);
-}
-
-static void sighandler_setup(void)
-{
-    struct sigaction act;
-
-    memset(&act, 0, sizeof(act));
-    act.sa_handler = termsig_handler;
-    sigaction(SIGINT,  &act, NULL);
-    sigaction(SIGHUP,  &act, NULL);
-    sigaction(SIGTERM, &act, NULL);
-
-    act.sa_handler = sigchld_handler;
-    act.sa_flags = SA_NOCLDSTOP;
-    sigaction(SIGCHLD, &act, NULL);
-}
-
-#endif
-
 #ifdef _WIN32
 /* Look for support files in the same directory as the executable.  */
 static char *find_datadir(const char *argv0)
@@ -3556,10 +3527,8 @@ int main(int argc, char **argv, char **envp)
 
     cpu_synchronize_all_post_init();
 
-#ifndef _WIN32
     /* must be after terminal init, SDL library changes signal handlers */
-    sighandler_setup();
-#endif
+    os_setup_signal_handling();
 
     set_numa_modes();
 
This page took 0.04172 seconds and 4 git commands to generate.