aboutsummaryrefslogtreecommitdiff
path: root/src/librc.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-04-20 18:58:42 +0000
committerRoy Marples <roy@marples.name>2007-04-20 18:58:42 +0000
commit35ee67f446277f5777a5b9f7feff3e37b315d9d0 (patch)
tree18582ab2a6ccc89bcefbfc9771c777b5ad68c7ba /src/librc.c
parenta5ba34ec151e4e18d7b732dac1517d21a1df3710 (diff)
Re-work the starting and stopping of services so we always know the pid so we can kill our children without the need for process groups which we cannot use as keyboard will not work in init.
Diffstat (limited to 'src/librc.c')
-rw-r--r--src/librc.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/librc.c b/src/librc.c
index 2a240a83..560359e1 100644
--- a/src/librc.c
+++ b/src/librc.c
@@ -445,8 +445,6 @@ static pid_t _exec_service (const char *service, const char *arg)
char *file;
char *fifo;
pid_t pid = -1;
- pid_t savedpid;
- int status;
char *svc;
file = rc_resolve_service (service);
@@ -483,15 +481,16 @@ static pid_t _exec_service (const char *service, const char *arg)
free (fifo);
free (file);
- if (pid == -1) {
+ if (pid == -1)
eerror ("vfork: %s", strerror (errno));
- return (pid);
- }
+
+ return (pid);
+}
- if (rc_is_env ("RC_PARALLEL_STARTUP", "yes"))
- return (pid);
+int rc_waitpid (pid_t pid) {
+ int status = 0;
+ pid_t savedpid = pid;
- savedpid = pid;
errno = 0;
do {
pid = waitpid (savedpid, &status, 0);
@@ -501,8 +500,8 @@ static pid_t _exec_service (const char *service, const char *arg)
return (-1);
}
} while (! WIFEXITED (status) && ! WIFSIGNALED (status));
-
- return (0);
+
+ return (WIFEXITED (status) ? WEXITSTATUS (status) : EXIT_FAILURE);
}
pid_t rc_stop_service (const char *service)