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)
(cherry picked from commit
bd28ae54a635667096e4a0d1010a1c3cce59712f)