From a854fe6d61257ff3dc6f4d2bc24baa42d80a9067 Mon Sep 17 00:00:00 2001
From: Roy Marples <roy@marples.name>
Date: Wed, 7 May 2008 09:47:07 +0000
Subject: Simplify the wait code.

---
 src/rc/rc-plugin.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/src/rc/rc-plugin.c b/src/rc/rc-plugin.c
index 55112f4a..92076730 100644
--- a/src/rc/rc-plugin.c
+++ b/src/rc/rc-plugin.c
@@ -121,24 +121,14 @@ void rc_plugin_load(void)
 int rc_waitpid(pid_t pid)
 {
 	int status;
-	pid_t savedpid = pid;
-
-loop:
-	pid = waitpid(savedpid, &status, 0);
-	if (pid == -1) {
-		/* Our signal hander should take appropriate action. */
-		if (errno == EINTR)
-			goto loop;
-		return EXIT_FAILURE;
-	}
-	
-	if (pid == savedpid) {
-		if (WIFEXITED(status))
-			return WEXITSTATUS(status);
-		return EXIT_FAILURE;
-	}
 
-	return EXIT_SUCCESS;
+	while (waitpid(pid, &status, 0) == -1) {
+		if (errno != EINTR) {
+			status = -1;
+			break;
+		}
+	}
+	return status;
 }
 
 void rc_plugin_run(RC_HOOK hook, const char *value)
-- 
cgit v1.2.3