From bb93ad418c771e7ba1a4256bf59cbe510102d1bd Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 3 Sep 2008 10:10:39 -0700 Subject: [PATCH] Also disable atexit hooks in fatal_signal_fork(). This fixes a problem in ofp-discover, where it would daemonize itself after setting an IP address on one of its interfaces. The daemonize function would call fatal_signal_fork() then exit(0), which would in turn cause the netdev code to disable the interface and thereby remove the IP address. The bug that this fixes was introduced in commit 3cc1ae6a3, "Add ability to run fatal signal hooks upon normal termination too." --- lib/fatal-signal.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/fatal-signal.c b/lib/fatal-signal.c index 95f54ff9..99b9d5e2 100644 --- a/lib/fatal-signal.c +++ b/lib/fatal-signal.c @@ -64,6 +64,9 @@ static int block_level = 0; /* Signal mask saved by outermost signal blocker. */ static sigset_t saved_signal_mask; +/* Disabled by fatal_signal_fork()? */ +static bool disabled; + static void call_sigprocmask(int how, sigset_t* new_set, sigset_t* old_set); static void atexit_handler(void); static void call_hooks(int sig_nr); @@ -156,7 +159,9 @@ fatal_signal_handler(int sig_nr) static void atexit_handler(void) { - call_hooks(0); + if (!disabled) { + call_hooks(0); + } } static void @@ -179,7 +184,6 @@ call_hooks(int sig_nr) static char **files; static size_t n_files, max_files; -static bool disabled; static void unlink_files(void *aux); static void do_unlink_files(void); @@ -231,12 +235,10 @@ unlink_files(void *aux UNUSED) static void do_unlink_files(void) { - if (!disabled) { - size_t i; + size_t i; - for (i = 0; i < n_files; i++) { - unlink(files[i]); - } + for (i = 0; i < n_files; i++) { + unlink(files[i]); } } -- 2.30.2