[LEDE-DEV] [PATCH 4/5] inittab: use patch_stdio() for stdio redirection

Jo-Philipp Wich jo at mein.io
Tue May 17 08:00:46 PDT 2016


Signed-off-by: Jo-Philipp Wich <jo at mein.io>
---
 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.1.4




More information about the Lede-dev mailing list