diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-09-04 17:53:23 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-09-05 16:31:13 +0100 |
commit | fc600b6a8f0dec5642b45c1026dee24c9adb9bc2 (patch) | |
tree | 517f6d98df94f8868a467935b5955bfe6c7bdc84 | |
parent | ad5b3128ba219c895ee084eb027a296b207df16b (diff) | |
download | dbus-fc600b6a8f0dec5642b45c1026dee24c9adb9bc2.tar.gz |
_dbus_babysitter_unref: avoid infinite loop if waitpid() returns EINTR
If waitpid() failed with EINTR, we'd go back for another go, but
because ret is nonzero, we'd skip the waitpid() and just keep looping.
Also avoid an unnecessary "goto" in favour of a proper loop, to make it
more clearly correct.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68945
Reviewed-by: Colin Walters <walters@verbum.org>
-rw-r--r-- | dbus/dbus-spawn.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index ef00801c..6e42f554 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -308,15 +308,18 @@ _dbus_babysitter_unref (DBusBabysitter *sitter) if (ret == 0) kill (sitter->sitter_pid, SIGKILL); - again: if (ret == 0) - ret = waitpid (sitter->sitter_pid, &status, 0); + { + do + { + ret = waitpid (sitter->sitter_pid, &status, 0); + } + while (_DBUS_UNLIKELY (ret < 0 && errno == EINTR)); + } if (ret < 0) { - if (errno == EINTR) - goto again; - else if (errno == ECHILD) + if (errno == ECHILD) _dbus_warn ("Babysitter process not available to be reaped; should not happen\n"); else _dbus_warn ("Unexpected error %d in waitpid() for babysitter: %s\n", |