process: block signals while spawning child processes
authorAnsis Atteka <aatteka@nicira.com>
Fri, 23 May 2014 21:15:28 +0000 (14:15 -0700)
committerAnsis Atteka <aatteka@nicira.com>
Fri, 30 May 2014 17:06:10 +0000 (10:06 -0700)
commit1481a7551da6893c08fb93bee9ac8293b90aa6a6
tree25fb78d87a2f9f1ea0e07be12d18415fa32f5e89
parent60032110f13552588f68443b646b869369a3f414
process: block signals while spawning child processes

Between fork() and execvp() calls in the process_start()
function both child and parent processes share the same
file descriptors.  This means that, if a child process
received a signal during this time interval, then it could
potentially write data to a shared file descriptor.

One such example is fatal signal handler, where, if
child process received SIGTERM signal, then it would
write data into pipe.  Then a read event would occur
on the other end of the pipe where parent process is
listening and this would make parent process to incorrectly
believe that it was the one who received SIGTERM.
Also, since parent process never reads data from this
pipe, then this bug would make parent process to consume
100% CPU by immediately waking up from the event loop.

This patch will help to avoid this problem by blocking
signals until child closes all its file descriptors.

Signed-off-by: Ansis Atteka <aatteka@nicira.com>
Reported-by: Suganya Ramachandran <suganyar@vmware.com>
Issue: 1255110
lib/fatal-signal.c
lib/fatal-signal.h
lib/ovs-thread.c
lib/ovs-thread.h
lib/process.c