|
|
e3782d |
From a4f11f83a4b8ba8c7feecd37c7606d0d792d7fe6 Mon Sep 17 00:00:00 2001
|
|
|
e3782d |
From: Simon McVittie <simon.mcvittie@collabora.co.uk>
|
|
|
e3782d |
Date: Wed, 4 Sep 2013 17:53:23 +0100
|
|
|
e3782d |
Subject: [PATCH] _dbus_babysitter_unref: avoid infinite loop if waitpid()
|
|
|
e3782d |
returns EINTR
|
|
|
e3782d |
|
|
|
e3782d |
If waitpid() failed with EINTR, we'd go back for another go, but
|
|
|
e3782d |
because ret is nonzero, we'd skip the waitpid() and just keep looping.
|
|
|
e3782d |
|
|
|
e3782d |
Also avoid an unnecessary "goto" in favour of a proper loop, to make it
|
|
|
e3782d |
more clearly correct.
|
|
|
e3782d |
|
|
|
e3782d |
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68945
|
|
|
e3782d |
---
|
|
|
e3782d |
dbus/dbus-spawn.c | 13 ++++++++-----
|
|
|
e3782d |
1 file changed, 8 insertions(+), 5 deletions(-)
|
|
|
e3782d |
|
|
|
e3782d |
diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c
|
|
|
e3782d |
index ef00801..6e42f55 100644
|
|
|
e3782d |
--- a/dbus/dbus-spawn.c
|
|
|
e3782d |
+++ b/dbus/dbus-spawn.c
|
|
|
e3782d |
@@ -308,15 +308,18 @@ _dbus_babysitter_unref (DBusBabysitter *sitter)
|
|
|
e3782d |
if (ret == 0)
|
|
|
e3782d |
kill (sitter->sitter_pid, SIGKILL);
|
|
|
e3782d |
|
|
|
e3782d |
- again:
|
|
|
e3782d |
if (ret == 0)
|
|
|
e3782d |
- ret = waitpid (sitter->sitter_pid, &status, 0);
|
|
|
e3782d |
+ {
|
|
|
e3782d |
+ do
|
|
|
e3782d |
+ {
|
|
|
e3782d |
+ ret = waitpid (sitter->sitter_pid, &status, 0);
|
|
|
e3782d |
+ }
|
|
|
e3782d |
+ while (_DBUS_UNLIKELY (ret < 0 && errno == EINTR));
|
|
|
e3782d |
+ }
|
|
|
e3782d |
|
|
|
e3782d |
if (ret < 0)
|
|
|
e3782d |
{
|
|
|
e3782d |
- if (errno == EINTR)
|
|
|
e3782d |
- goto again;
|
|
|
e3782d |
- else if (errno == ECHILD)
|
|
|
e3782d |
+ if (errno == ECHILD)
|
|
|
e3782d |
_dbus_warn ("Babysitter process not available to be reaped; should not happen\n");
|
|
|
e3782d |
else
|
|
|
e3782d |
_dbus_warn ("Unexpected error %d in waitpid() for babysitter: %s\n",
|
|
|
e3782d |
--
|
|
|
e3782d |
1.8.4.rc3
|
|
|
e3782d |
|