mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-10-06 05:39:20 +02:00
gmain: Reset signal handlers to default when source is destroyed
If someone creates a unix signal source for e.g. SIGINT, and then removes it, reset the handler to SIG_DFL. Not doing this was the source of race conditions in the glib/tests/unix test, but this will also just make us a "good citizen" by cleaning up. For example, if a project temporarily creates a handler for SIGTERM, and then later removes it, they almost certainly want SIGTERM to revert to the default of terminating the process, rather than doing nothing. https://bugzilla.gnome.org/show_bug.cgi?id=704699
This commit is contained in:
@@ -158,18 +158,15 @@ test_sigterm (void)
|
||||
static void
|
||||
test_sighup_add_remove (void)
|
||||
{
|
||||
GMainLoop *mainloop;
|
||||
guint id;
|
||||
|
||||
mainloop = g_main_loop_new (NULL, FALSE);
|
||||
struct sigaction action;
|
||||
|
||||
sig_received = FALSE;
|
||||
id = g_unix_signal_add (SIGHUP, on_sig_received, mainloop);
|
||||
id = g_unix_signal_add (SIGHUP, on_sig_received, NULL);
|
||||
g_source_remove (id);
|
||||
kill (getpid (), SIGHUP);
|
||||
g_assert (!sig_received);
|
||||
g_main_loop_unref (mainloop);
|
||||
|
||||
sigaction (SIGHUP, NULL, &action);
|
||||
g_assert (action.sa_handler == SIG_DFL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
Reference in New Issue
Block a user