From: Jo-Philipp Wich Date: Tue, 17 May 2016 15:00:46 +0000 (+0200) Subject: inittab: use patch_stdio() for stdio redirection X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=38dd221a41ca93155b0427be4f5d536173dbd111;p=oweals%2Fprocd.git inittab: use patch_stdio() for stdio redirection Signed-off-by: Jo-Philipp Wich --- diff --git a/inittab.c b/inittab.c index f8f0218..622601a 100644 --- a/inittab.c +++ b/inittab.c @@ -93,22 +93,14 @@ static int dev_exist(const char *dev) static void fork_worker(struct init_action *a) { - int fd; pid_t p; a->proc.pid = fork(); if (!a->proc.pid) { p = setsid(); - fd = dev_open(a->id); - if (fd != -1) - { - dup2(fd, STDIN_FILENO); - dup2(fd, STDOUT_FILENO); - dup2(fd, STDERR_FILENO); - if (fd > STDERR_FILENO) - close(fd); - } + if (patch_stdio(a->id)) + ERROR("Failed to setup i/o redirection\n"); ioctl(STDIN_FILENO, TIOCSCTTY, 1); tcsetpgrp(STDIN_FILENO, p);