diff options
author | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-04-07 15:35:19 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-04-07 16:19:38 +0200 |
commit | b81668e045b6a2105b7b0b9e2e5afa8e631e6ec5 (patch) | |
tree | 6b37e483b49c52467a0ba1a62c416e2b5ada763f /initd/runlst.c | |
parent | 43274e3910d2a910262d1192e663db1d983f8e54 (diff) |
Minor cleanup
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'initd/runlst.c')
-rw-r--r-- | initd/runlst.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/initd/runlst.c b/initd/runlst.c index 49b7def..7840aff 100644 --- a/initd/runlst.c +++ b/initd/runlst.c @@ -16,26 +16,15 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <sys/wait.h> -#include <signal.h> #include <unistd.h> #include <stdlib.h> -#include <string.h> #include <stdio.h> -#include <errno.h> -#include <ctype.h> #include <fcntl.h> #include "init.h" extern char **environ; -static NORETURN void split_and_exec(exec_t *cmd) -{ - execve(cmd->argv[0], cmd->argv, environ); - perror(cmd->argv[0]); - exit(EXIT_FAILURE); -} - static int child_setup(const char *ctty) { sigset_t mask; @@ -77,7 +66,9 @@ int runlst_wait(exec_t *list, const char *ctty) if (pid == 0) { if (child_setup(ctty)) exit(EXIT_FAILURE); - split_and_exec(list); + execve(list->argv[0], list->argv, environ); + perror(list->argv[0]); + exit(EXIT_FAILURE); } if (pid == -1) { @@ -101,21 +92,18 @@ int runlst_wait(exec_t *list, const char *ctty) pid_t runlst(exec_t *list, const char *ctty) { - int status; - pid_t pid; - - pid = fork(); + pid_t pid = fork(); if (pid == 0) { if (child_setup(ctty)) exit(EXIT_FAILURE); - if (list->next != NULL) { - status = runlst_wait(list, NULL); - exit(status); - } else { - split_and_exec(list); - } + if (list->next != NULL) + exit(runlst_wait(list, NULL)); + + execve(list->argv[0], list->argv, environ); + perror(list->argv[0]); + exit(EXIT_FAILURE); } if (pid == -1) |