From: Ben Pfaff Date: Tue, 23 Mar 2010 22:27:44 +0000 (-0700) Subject: fatal-signal: Initialize library upon any call to public function. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c874f17fc743b38295f6059ab6554561b7555724;p=openvswitch fatal-signal: Initialize library upon any call to public function. 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. --- diff --git a/lib/fatal-signal.c b/lib/fatal-signal.c index 80ecfc35..f6f913eb 100644 --- a/lib/fatal-signal.c +++ b/lib/fatal-signal.c @@ -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); }