aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsapier <Sapier at GMX dot net>2014-06-01 00:41:48 +0200
committersapier <Sapier at GMX dot net>2014-06-01 00:41:48 +0200
commitc5f00c38da336ed929a5b1613a4b2e7fef42adbe (patch)
treefb19dbafc3ff8c25431b8ddf2d105740eeba4e57 /src
parent34904a0744ee08d387a67619a5e2c46ce4928c12 (diff)
downloadminetest-c5f00c38da336ed929a5b1613a4b2e7fef42adbe.tar.gz
minetest-c5f00c38da336ed929a5b1613a4b2e7fef42adbe.tar.bz2
minetest-c5f00c38da336ed929a5b1613a4b2e7fef42adbe.zip
Redirect stdin/stderr/stdout to /dev/null in daemon mode
Diffstat (limited to 'src')
-rw-r--r--src/porting.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/porting.cpp b/src/porting.cpp
index ef461242d..ca43452a8 100644
--- a/src/porting.cpp
+++ b/src/porting.cpp
@@ -635,6 +635,7 @@ void daemonize()
pidfile = 0;
}
+
pid_t pid = fork();
if (pid > 0) {
@@ -648,8 +649,9 @@ void daemonize()
}
exit (0);
} else if (pid == 0) {
- fclose(stdout);
- fclose(stderr);
+ freopen("/dev/null","w",stdout);
+ freopen("/dev/null","w",stderr);
+ freopen("/dev/null","r",stdout);
return;
}