aboutsummaryrefslogtreecommitdiffstats
path: root/vl.c
diff options
context:
space:
mode:
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/vl.c b/vl.c
index a4838b410..df7b7a691 100644
--- a/vl.c
+++ b/vl.c
@@ -7621,6 +7621,8 @@ static int main_loop(void)
timeout = 0;
}
} else {
+ if (shutdown_requested)
+ break;
timeout = 10;
}
#ifdef CONFIG_PROFILER
@@ -8185,6 +8187,26 @@ static BOOL WINAPI qemu_ctrl_handler(DWORD type)
#define MAX_NET_CLIENTS 32
+#ifndef _WIN32
+
+static void termsig_handler(int signal)
+{
+ qemu_system_shutdown_request();
+}
+
+void termsig_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);
+}
+
+#endif
+
int main(int argc, char **argv)
{
#ifdef CONFIG_GDBSTUB
@@ -9073,6 +9095,11 @@ int main(int argc, char **argv)
#endif
}
+#ifndef _WIN32
+ /* must be after terminal init, SDL library changes signal handlers */
+ termsig_setup();
+#endif
+
/* Maintain compatibility with multiple stdio monitors */
if (!strcmp(monitor_device,"stdio")) {
for (i = 0; i < MAX_SERIAL_PORTS; i++) {