From 38dd221a41ca93155b0427be4f5d536173dbd111 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 17 May 2016 17:00:46 +0200 Subject: [PATCH] inittab: use patch_stdio() for stdio redirection Signed-off-by: Jo-Philipp Wich --- inittab.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) 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); -- 2.30.2