lib/tevent: fix race with signals and tevent_common_add_signal
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 28 Aug 2009 02:34:22 +0000 (12:04 +0930)
committerKarolin Seeger <kseeger@samba.org>
Wed, 9 Sep 2009 10:27:17 +0000 (12:27 +0200)
commitbd28ae54a635667096e4a0d1010a1c3cce59712f
treed3f4de17efe8b7c6a8ea1141065dfa9ea27bd4c1
parentfdcc157d51cce8561df37fa9eed39332772bacb9
lib/tevent: fix race with signals and tevent_common_add_signal

We carefully preserve the old signal handler, but we replace it before
we've set up everything; in particular, if we fail setting up the
pipe_hack we could write a NUL char to stdout (fd 0), instead of
calling the old signal handler.

Replace the signal handler as the very last thing we do.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(cherry picked from commit 6abb637e3e0d23635fdbbb91c163731b325d696d)
lib/tevent/tevent_signal.c