diff options
author | attilamolnar <attilamolnar@hush.com> | 2012-12-03 00:34:59 +0100 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2012-12-03 17:51:52 +0100 |
commit | d86426f359dcc5eef5a5534e6579af7b38b5beed (patch) | |
tree | c4fa4141087c96831a4825aec03714e79e040166 /src | |
parent | 01a1d67dd1406f99821c7c5f6e491373bbd96c74 (diff) |
Properly shut down stdin
Replace hardcoded ints
Diffstat (limited to 'src')
-rw-r--r-- | src/inspircd.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 0a3bc1820..36acf65cd 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -630,18 +630,17 @@ InspIRCd::InspIRCd(int argc, char** argv) : */ if ((!do_nofork) && (!do_testsuite) && (!Config->cmdline.forcedebug)) { - int fd; + int fd = open("/dev/null", O_RDWR); fclose(stdin); fclose(stderr); fclose(stdout); - fd = open("/dev/null", O_RDWR); - if (dup2(fd, 0) < 0) + if (dup2(fd, STDIN_FILENO) < 0) Logs->Log("STARTUP", DEFAULT, "Failed to dup /dev/null to stdin."); - if (dup2(fd, 1) < 0) + if (dup2(fd, STDOUT_FILENO) < 0) Logs->Log("STARTUP", DEFAULT, "Failed to dup /dev/null to stdout."); - if (dup2(fd, 2) < 0) + if (dup2(fd, STDERR_FILENO) < 0) Logs->Log("STARTUP", DEFAULT, "Failed to dup /dev/null to stderr."); close(fd); } |