[LEDE-DEV] [PATCH 3/5] initd: use patch_stdio() for kmodloader stdio redirection

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


Signed-off-by: Jo-Philipp Wich <jo at mein.io>
---
 initd/init.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/initd/init.c b/initd/init.c
index 4d17563..e453cff 100644
--- a/initd/init.c
+++ b/initd/init.c
@@ -86,17 +86,9 @@ main(int argc, char **argv)
 	if (!pid) {
 		char *kmod[] = { "/sbin/kmodloader", "/etc/modules-boot.d/", NULL };
 
-		if (debug < 3) {
-			int fd = open("/dev/null", O_RDWR);
-
-			if (fd > -1) {
-				dup2(fd, STDIN_FILENO);
-				dup2(fd, STDOUT_FILENO);
-				dup2(fd, STDERR_FILENO);
-				if (fd > STDERR_FILENO)
-					close(fd);
-			}
-		}
+		if (debug < 3)
+			patch_stdio("/dev/null");
+
 		execvp(kmod[0], kmod);
 		ERROR("Failed to start kmodloader\n");
 		exit(-1);
-- 
2.1.4




More information about the Lede-dev mailing list