mirror of
https://github.com/bjc/prosody.git
synced 2025-04-06 22:57:38 +03:00
util.pposix: Use freopen(3) when replacing standard IO streams (thanks ratchetfreak)
Man page says this is what freopen(3) is for.
This commit is contained in:
parent
0e28ada219
commit
39c7ba2a8f
1 changed files with 3 additions and 7 deletions
|
@ -104,14 +104,10 @@ static int lc_daemonize(lua_State *L) {
|
|||
return 2;
|
||||
}
|
||||
|
||||
/* Close stdin, stdout, stderr */
|
||||
close(0);
|
||||
close(1);
|
||||
close(2);
|
||||
/* Make sure accidental use of FDs 0, 1, 2 don't cause weirdness */
|
||||
open("/dev/null", O_RDONLY);
|
||||
open("/dev/null", O_WRONLY);
|
||||
open("/dev/null", O_WRONLY);
|
||||
stdin = freopen("/dev/null", "r", stdin);
|
||||
stdout = freopen("/dev/null", "w", stdout);
|
||||
stderr = freopen("/dev/null", "w", stderr);
|
||||
|
||||
/* Final fork, use it wisely */
|
||||
if(fork()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue