fatal-signal: Initialize library upon any call to public function.
authorBen Pfaff <blp@nicira.com>
Tue, 23 Mar 2010 22:27:44 +0000 (15:27 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 24 Mar 2010 23:52:07 +0000 (16:52 -0700)
Not calling fatal_signal_init() means that the signal handlers don't get
registered, so the process won't clean up on fatal signals.  Furthermore,
signal_fds[0] is then 0, which means that fatal-signal_wait() waits on
stdin, so if you are testing a program interactively and accidentally type
something on stdin then that program's CPU usage jumps to 100%.

Since poll_block() calls fatal_signal_wait() this seems like the most
reliable solution.

lib/fatal-signal.c

index 80ecfc35aaf820d1719ac66b0ebc2f7924b66af2..f6f913ebc0b1d2aa19923240344f40c88df37384 100644 (file)
@@ -137,8 +137,11 @@ fatal_signal_handler(int sig_nr)
 void
 fatal_signal_run(void)
 {
-    int sig_nr = stored_sig_nr;
+    int sig_nr;
 
+    fatal_signal_init();
+
+    sig_nr = stored_sig_nr;
     if (sig_nr != SIG_ATOMIC_MAX) {
         call_hooks(sig_nr);
 
@@ -152,6 +155,7 @@ fatal_signal_run(void)
 void
 fatal_signal_wait(void)
 {
+    fatal_signal_init();
     poll_fd_wait(signal_fds[0], POLLIN);
 }