]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: signal: signal_unregister() removes every handlers
authorWilliam Lallemand <wlallemand@haproxy.com>
Tue, 20 Nov 2018 16:36:52 +0000 (17:36 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 22 Nov 2018 10:42:51 +0000 (11:42 +0100)
The new function signal_unregister() removes every handlers assigned to
a signal. Once the handler list of the signal is empty, the signal is
ignored with SIG_IGN.

include/proto/signal.h
src/signal.c

index b61a52725d8ed804287f1c865de322dabaa80bd4..0806d04225871ac6ca1afc94b2f08916f47298f5 100644 (file)
@@ -32,6 +32,7 @@ struct sig_handler *signal_register_fct(int sig, void (*fct)(struct sig_handler
 struct sig_handler *signal_register_task(int sig, struct task *task, int reason);
 void signal_unregister_handler(struct sig_handler *handler);
 void signal_unregister_target(int sig, void *target);
+void signal_unregister(int sig);
 void haproxy_unblock_signals();
 
 static inline void signal_process_queue()
index 75d5c65a3a740ae04e126587d9a087688147be81..93877284c59c8e5102d702500d555c5c60f4dc6b 100644 (file)
@@ -254,3 +254,23 @@ void signal_unregister_target(int sig, void *target)
                }
        }
 }
+
+/*
+ * Immedialtely unregister every handler assigned to a signal <sig>.
+ * Once the handler list is empty, the signal is ignored with SIG_IGN.
+ */
+
+void signal_unregister(int sig)
+{
+       struct sig_handler *sh, *shb;
+
+       if (sig < 0 || sig >= MAX_SIGNAL)
+               return;
+
+       list_for_each_entry_safe(sh, shb, &signal_state[sig].handlers, list) {
+               LIST_DEL(&sh->list);
+               pool_free(pool_head_sig_handlers, sh);
+       }
+
+       signal(sig, SIG_IGN);
+}