mirror of
https://github.com/openvswitch/ovs
synced 2025-09-01 06:45:17 +00:00
daemon: Tolerate EINTR in fork_and_wait_for_startup().
It seems possible that a signal coming in at the wrong time could confuse this code. It's always best to loop on EINTR.
This commit is contained in:
@@ -244,11 +244,12 @@ fork_and_wait_for_startup(int *fdp)
|
|||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid > 0) {
|
if (pid > 0) {
|
||||||
/* Running in parent process. */
|
/* Running in parent process. */
|
||||||
|
size_t bytes_read;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
close(fds[1]);
|
close(fds[1]);
|
||||||
fatal_signal_fork();
|
fatal_signal_fork();
|
||||||
if (read(fds[0], &c, 1) != 1) {
|
if (read_fully(fds[0], &c, 1, &bytes_read) != 0) {
|
||||||
int retval;
|
int retval;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
@@ -213,10 +213,15 @@ def _fork_and_wait_for_startup():
|
|||||||
# Running in parent process.
|
# Running in parent process.
|
||||||
os.close(wfd)
|
os.close(wfd)
|
||||||
ovs.fatal_signal.fork()
|
ovs.fatal_signal.fork()
|
||||||
try:
|
while True:
|
||||||
s = os.read(rfd, 1)
|
try:
|
||||||
except OSError, e:
|
s = os.read(rfd, 1)
|
||||||
s = ""
|
error = 0
|
||||||
|
except OSError, e:
|
||||||
|
s = ""
|
||||||
|
error = e.errno
|
||||||
|
if error != errno.EINTR:
|
||||||
|
break
|
||||||
if len(s) != 1:
|
if len(s) != 1:
|
||||||
retval, status = _waitpid(pid, 0)
|
retval, status = _waitpid(pid, 0)
|
||||||
if (retval == pid and
|
if (retval == pid and
|
||||||
|
Reference in New Issue
Block a user