Branch: refs/heads/master Author: Matthew Brush matt@geany.org Committer: Matthew Brush mbrush@codebrainz.ca Date: Fri, 04 Aug 2017 09:22:04 UTC Commit: a108f9162cc98e501e2458cd8b35c499b7f87384 https://github.com/geany/geany/commit/a108f9162cc98e501e2458cd8b35c499b7f873...
Log Message: ----------- Re-enable SIGTERM handling
Now that a new enough GLib is available the signal can be handled cleanly on the main loop using the GSource for Unix signals. This replaces the illegal SIGTERM handling that was disabled in fbb89f523af47b35e238678d348cfa98e56c760a.
Closes #1255
Modified Paths: -------------- src/libmain.c
Modified: src/libmain.c 21 lines changed, 14 insertions(+), 7 deletions(-) =================================================================== @@ -76,6 +76,10 @@
#include <glib/gstdio.h>
+#ifdef G_OS_UNIX +# include <glib-unix.h> +#endif + #ifdef HAVE_LOCALE_H # include <locale.h> #endif @@ -773,16 +777,20 @@ static gint setup_config_dir(void) return mkdir_result; }
-/* Signal handling removed since main_quit() uses functions that are - * illegal in signal handlers -static void signal_cb(gint sig) + +#ifdef G_OS_UNIX +static gboolean signal_cb(gpointer user_data) { + gint sig = GPOINTER_TO_INT(user_data); if (sig == SIGTERM) { + geany_debug("Received SIGTERM signal"); main_quit(); } + return G_SOURCE_REMOVE; } - */ +#endif +
/* Used for command-line arguments at startup or from socket. * this will strip any :line:col filename suffix from locale_filename */ @@ -1068,10 +1076,9 @@ gint main_lib(gint argc, gchar **argv) g_thread_init(NULL); #endif
- /* removed as signal handling was wrong, see signal_cb() - signal(SIGTERM, signal_cb); */ - #ifdef G_OS_UNIX + g_unix_signal_add(SIGTERM, signal_cb, GINT_TO_POINTER(SIGTERM)); + /* ignore SIGPIPE signal for preventing sudden death of program */ signal(SIGPIPE, SIG_IGN); #endif
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).