aboutsummaryrefslogtreecommitdiff
path: root/init/init.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-03-17 22:01:42 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-03-17 22:01:42 +0000
commite421b5ebf6b2484455ea36bb6c98deff685088e3 (patch)
tree38f0cb4bc09f2409b15b0096bed964fb098108e1 /init/init.c
parent2724fa9d8a076f52c158627877d59894789b09a1 (diff)
downloadbusybox-e421b5ebf6b2484455ea36bb6c98deff685088e3.tar.gz
init: do not close all descriptors > 2. We were doing it - sometimes.
Good choices are "do it, always" or "don't do it". Second is smaller.
Diffstat (limited to 'init/init.c')
-rw-r--r--init/init.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/init/init.c b/init/init.c
index eefb9df55..c4674a55f 100644
--- a/init/init.c
+++ b/init/init.c
@@ -214,8 +214,7 @@ static void console_init(void)
if (fd >= 0) {
dup2(fd, 0);
dup2(fd, 1);
- dup2(fd, 2);
- while (fd > 2) close(fd--);
+ xmove_fd(fd, 2);
}
messageD(L_LOG, "console='%s'", s);
} else {
@@ -223,7 +222,7 @@ static void console_init(void)
* (so that they won't be used by future opens) */
/* bb_sanitize_stdio(); - WRONG.
- * Fail if "/dev/null" doesnt exist, and for init
+ * It fails if "/dev/null" doesnt exist, and for init
* this is a real possibility! Open code it instead. */
int fd = open(bb_dev_null, O_RDWR);
@@ -234,11 +233,11 @@ static void console_init(void)
while ((unsigned)fd < 2)
fd = dup(fd);
if (fd > 2)
- close (fd);
+ close(fd);
}
s = getenv("TERM");
- if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
+ if (ioctl(STDIN_FILENO, TIOCGSERIAL, &sr) == 0) {
/* Force the TERM setting to vt102 for serial console
* if TERM is set to linux (the default) */
if (!s || strcmp(s, "linux") == 0)