summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJo-Philipp Wich2016-05-17 15:00:44 +0000
committerJohn Crispin2016-05-16 19:00:17 +0000
commitd38403cdd3ba8427a2d24ba68f1ba79f4dd0546b (patch)
treeb41eb4c07a036293ee7afd9e65ca05983c14b1ae
parent9f3b9ddf1a94b03e463f5354b48808a9f05d38bb (diff)
downloadprocd-d38403cdd3ba8427a2d24ba68f1ba79f4dd0546b.tar.gz
initd: use patch_stdio() for early console setup
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--initd/early.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/initd/early.c b/initd/early.c
index 4343516..accfc1d 100644
--- a/initd/early.c
+++ b/initd/early.c
@@ -21,6 +21,7 @@
#include <unistd.h>
#include <stdlib.h>
+#include "../utils/utils.h"
#include "init.h"
#include "../libc-compat.h"
@@ -35,25 +36,16 @@ static void
early_console(const char *dev)
{
struct stat s;
- int dd;
if (stat(dev, &s)) {
ERROR("Failed to stat %s\n", dev);
return;
}
- dd = open(dev, O_RDWR);
- if (dd < 0)
- dd = open("/dev/null", O_RDWR);
-
- dup2(dd, STDIN_FILENO);
- dup2(dd, STDOUT_FILENO);
- dup2(dd, STDERR_FILENO);
-
- if (dd != STDIN_FILENO &&
- dd != STDOUT_FILENO &&
- dd != STDERR_FILENO)
- close(dd);
+ if (patch_stdio(dev)) {
+ ERROR("Failed to setup i/o redirection\n");
+ return;
+ }
fcntl(STDERR_FILENO, F_SETFL, fcntl(STDERR_FILENO, F_GETFL) | O_NONBLOCK);
}