]> Zhao Yanbai Git Server - minix.git/commitdiff
Open stdin, stdout and stderr only after /etc/rc has executed. (/etc/rc
authorBen Gras <ben@minix3.org>
Thu, 11 Dec 2008 14:43:25 +0000 (14:43 +0000)
committerBen Gras <ben@minix3.org>
Thu, 11 Dec 2008 14:43:25 +0000 (14:43 +0000)
executes it itself.) This avoids keeping /dev nodes on the temporary
root filesystem (initial mfs) in use unnecessarily.

servers/init/init.c

index 7d32818dabaa51c760b9f14261cdc7ba38c1dd49..5fd15fd3e40398fa472f3f7b4b9d65c141d62cec 100644 (file)
@@ -74,11 +74,12 @@ int main(void)
   struct sigaction sa;
   struct stat stb;
 
-  if (fstat(0, &stb) < 0) {
-       /* Open standard input, output & error. */
-       (void) open("/dev/null", O_RDONLY);
-       (void) open("/dev/log", O_WRONLY);
-       dup(1);
+#define OPENFDS                                                \
+  if (fstat(0, &stb) < 0) {                            \
+       /* Open standard input, output & error. */      \
+       (void) open("/dev/null", O_RDONLY);             \
+       (void) open("/dev/log", O_WRONLY);              \
+       dup(1);                                         \
   }
 
   sigemptyset(&sa.sa_mask);
@@ -123,6 +124,8 @@ int main(void)
        _exit(1);       /* impossible, we hope */
   }
 
+  OPENFDS;
+
   /* Clear /etc/utmp if it exists. */
   if ((fd = open(PATH_UTMP, O_WRONLY | O_TRUNC)) >= 0) close(fd);