atexit(curses_atexit);
#ifndef _WIN32
- signal(SIGINT, SIG_DFL);
- signal(SIGQUIT, SIG_DFL);
#if defined(SIGWINCH) && defined(KEY_RESIZE)
/* some curses implementations provide a handler, but we
* want to be sure this is handled regardless of the library */
sdl_process_key(&ev->key);
break;
case SDL_QUIT:
- if (!no_quit) {
+ if (!no_quit)
qemu_system_shutdown_request();
- vm_start(); /* In case we're paused */
- }
break;
case SDL_MOUSEMOTION:
if (gui_grab || kbd_mouse_is_absolute() ||
fprintf(stderr, "Could not initialize SDL - exiting\n");
exit(1);
}
-#ifndef _WIN32
- /* NOTE: we still want Ctrl-C to work, so we undo the SDL redirections */
- signal(SIGINT, SIG_DFL);
- signal(SIGQUIT, SIG_DFL);
-#endif
ds->dpy_update = sdl_update;
ds->dpy_resize = sdl_resize;
timeout = 0;
}
} else {
+ if (shutdown_requested)
+ break;
timeout = 10;
}
#ifdef CONFIG_PROFILER
#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
#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++) {