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.

This commit is contained in:
Roy Marples
2007-04-20 18:58:42 +00:00
parent a5ba34ec15
commit 35ee67f446
4 changed files with 142 additions and 47 deletions

View File

@ -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)