Open stdin, stdout and stderr only after /etc/rc has executed. (/etc/rc
executes it itself.) This avoids keeping /dev nodes on the temporary root filesystem (initial mfs) in use unnecessarily.
This commit is contained in:
parent
1d8aed840c
commit
e9f0c576a3
1 changed files with 8 additions and 5 deletions
|
@ -74,11 +74,12 @@ int main(void)
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
struct stat stb;
|
struct stat stb;
|
||||||
|
|
||||||
if (fstat(0, &stb) < 0) {
|
#define OPENFDS \
|
||||||
/* Open standard input, output & error. */
|
if (fstat(0, &stb) < 0) { \
|
||||||
(void) open("/dev/null", O_RDONLY);
|
/* Open standard input, output & error. */ \
|
||||||
(void) open("/dev/log", O_WRONLY);
|
(void) open("/dev/null", O_RDONLY); \
|
||||||
dup(1);
|
(void) open("/dev/log", O_WRONLY); \
|
||||||
|
dup(1); \
|
||||||
}
|
}
|
||||||
|
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
|
@ -123,6 +124,8 @@ int main(void)
|
||||||
_exit(1); /* impossible, we hope */
|
_exit(1); /* impossible, we hope */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OPENFDS;
|
||||||
|
|
||||||
/* Clear /etc/utmp if it exists. */
|
/* Clear /etc/utmp if it exists. */
|
||||||
if ((fd = open(PATH_UTMP, O_WRONLY | O_TRUNC)) >= 0) close(fd);
|
if ((fd = open(PATH_UTMP, O_WRONLY | O_TRUNC)) >= 0) close(fd);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue