aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2020-05-31 20:51:36 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2020-05-31 20:51:36 -0400
commit7c45cfc103e49840fd49b54ebc0a34c88a623f01 (patch)
tree5025e7a9c40d329bc505cdd4396fe44786f77faa /src/main.c
parent34ef1f25a6bb7f52d230885eb95f4b11a388412b (diff)
parentf3179749aec8eec40166576bef7e0daf893939d4 (diff)
Update upstream source from tag 'upstream/1.1.7'
Update to upstream version '1.1.7' with Debian dir 4ddb09241810e51ff3dfee9af3e56a170c38f1e5
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c
index 89128b4..62b9877 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2002-2003 Erik Fears
- * Copyright (c) 2014-2019 ircd-hybrid development team
+ * Copyright (c) 2014-2020 ircd-hybrid development team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -157,10 +157,20 @@ main(int argc, char *argv[])
/* Reset file mode. */
umask(077); /* umask 077: u=rwx,g=,o= */
- /* Close file descriptors. */
- close(STDIN_FILENO);
- close(STDOUT_FILENO);
- close(STDERR_FILENO);
+ /* Connect stdin, stdout, and stderr to /dev/null */
+ int fd = open("/dev/null", O_RDWR);
+ if (fd < 0)
+ {
+ perror("open()");
+ exit(EXIT_FAILURE);
+ }
+
+ dup2(fd, STDIN_FILENO);
+ dup2(fd, STDOUT_FILENO);
+ dup2(fd, STDERR_FILENO);
+
+ if (fd > STDERR_FILENO)
+ close(fd);
log_open(LOGFILE);
}