Skip to content

Commit

Permalink
Re-enable SIGTERM handling
Browse files Browse the repository at this point in the history
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
fbb89f5.

Closes #1255
  • Loading branch information
codebrainz committed Aug 4, 2017
1 parent fd38a49 commit a108f91
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/libmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a108f91

Please sign in to comment.