LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File xmms-1.2.11-sigterm.diff of Package xmms (Project home:donharter:home:FreeCAD)

--- xmms/main.c
+++ xmms/main.c
@@ -3678,6 +3678,18 @@
 	exit(1);
 }
 
+/* Try to exit nicely when receiving a nice exit signal */
+void sigterm_handler(int sig)
+{
+	/* Original author of patch said that you should not use mainwin_quit_cb(),
+	 * but his way deadlock xmms, and it anyhow just calls ctrlsocket stuff with
+	 * with CMD_QUIT, which anyhow calls mainwin_quit_cb() in turn.  This is not
+	 * entirely clean, but works.
+	 * <azarah@gentoo.org> (19 Jan 2003)
+	xmms_remote_quit(ctrlsocket_get_session_id()); */
+	mainwin_quit_cb();
+}
+
 static gboolean pposition_configure(GtkWidget *w, GdkEventConfigure *event, gpointer data)
 {
 	gint x,y;
@@ -3809,6 +3821,8 @@
 #endif
 
 	signal(SIGPIPE, SIG_IGN); /* for controlsocket.c */
+	signal(SIGTERM, sigterm_handler);
+	signal(SIGINT, sigterm_handler);
 	signal(SIGSEGV, segfault_handler);
 	g_thread_init(NULL);
 	gtk_set_locale();