summaryrefslogtreecommitdiff
path: root/src/runscript.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-10-05 11:04:49 +0000
committerRoy Marples <roy@marples.name>2007-10-05 11:04:49 +0000
commit9ff89f8027fa904737f15d59e2c3b26950391933 (patch)
tree0f5edbb4e68125b994c2002a0311d9bad44725e5 /src/runscript.c
parent3bfba57f5b2d89a5022fac932e46ca467a4b9f26 (diff)
downloadopenrc-9ff89f8027fa904737f15d59e2c3b26950391933.tar.gz
openrc-9ff89f8027fa904737f15d59e2c3b26950391933.tar.bz2
openrc-9ff89f8027fa904737f15d59e2c3b26950391933.tar.xz
Punt rc_waitpid
Diffstat (limited to 'src/runscript.c')
-rw-r--r--src/runscript.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/runscript.c b/src/runscript.c
index 1a03860..bfec680 100644
--- a/src/runscript.c
+++ b/src/runscript.c
@@ -331,6 +331,21 @@ static int write_prefix (const char *buffer, size_t bytes, bool *prefixed) {
return (ret);
}
+static int wait_pid (pid_t pid)
+{
+ int status = 0;
+ pid_t savedpid = pid;
+ int retval = -1;
+
+ errno = 0;
+ while ((pid = waitpid (savedpid, &status, 0)) > 0) {
+ if (pid == savedpid)
+ retval = WIFEXITED (status) ? WEXITSTATUS (status) : EXIT_FAILURE;
+ }
+
+ return (retval);
+}
+
static bool svc_exec (const char *arg1, const char *arg2)
{
bool execok;
@@ -437,7 +452,7 @@ static bool svc_exec (const char *arg1, const char *arg2)
master_tty = -1;
}
- execok = rc_waitpid (service_pid) == 0 ? true : false;
+ execok = wait_pid (service_pid) == 0 ? true : false;
service_pid = 0;
return (execok);
@@ -618,7 +633,7 @@ static void svc_start (bool deps)
if (rc_service_state (svc) & RC_SERVICE_STOPPED) {
pid_t pid = rc_service_start (svc);
if (! rc_env_bool ("RC_PARALLEL"))
- rc_waitpid (pid);
+ wait_pid (pid);
}
}
@@ -849,7 +864,7 @@ static void svc_stop (bool deps)
{
pid_t pid = rc_service_stop (svc);
if (! rc_env_bool ("RC_PARALLEL"))
- rc_waitpid (pid);
+ wait_pid (pid);
rc_strlist_add (&tmplist, svc);
}
}