version 1.70, 2009/01/22 10:02:34 |
version 1.71, 2009/02/21 19:32:04 |
|
|
int nullfd, dupfd; |
int nullfd, dupfd; |
|
|
if ((nullfd = dupfd = open(_PATH_DEVNULL, O_RDWR)) == -1) { |
if ((nullfd = dupfd = open(_PATH_DEVNULL, O_RDWR)) == -1) { |
fprintf(stderr, "Couldn't open /dev/null: %s", strerror(errno)); |
fprintf(stderr, "Couldn't open /dev/null: %s\n", |
|
strerror(errno)); |
exit(1); |
exit(1); |
} |
} |
while (++dupfd <= 2) { |
while (++dupfd <= 2) { |
|
|
if (fcntl(dupfd, F_GETFL, 0) >= 0) |
if (fcntl(dupfd, F_GETFL, 0) >= 0) |
continue; |
continue; |
if (dup2(nullfd, dupfd) == -1) { |
if (dup2(nullfd, dupfd) == -1) { |
fprintf(stderr, "dup2: %s", strerror(errno)); |
fprintf(stderr, "dup2: %s\n", strerror(errno)); |
exit(1); |
exit(1); |
} |
} |
} |
} |