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