projects
/
zefram
/
minetest
/
minetest_engine.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
34904a0
)
Redirect stdin/stderr/stdout to /dev/null in daemon mode
author
sapier
<Sapier at GMX dot net>
Sat, 31 May 2014 22:41:48 +0000
(
00:41
+0200)
committer
sapier
<Sapier at GMX dot net>
Sat, 31 May 2014 22:41:48 +0000
(
00:41
+0200)
src/porting.cpp
patch
|
blob
|
history
diff --git
a/src/porting.cpp
b/src/porting.cpp
index ef461242d28cad1afb37e34c889d3d9df55cfe71..ca43452a85439f56d494518fefc0eb008e0adedd 100644
(file)
--- 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;
}