icingacli web serve: redirect standard I/O to /dev/null after fork(2)

This commit is contained in:
Alexander A. Klimov 2019-05-10 15:19:53 +02:00
parent 8e84bdf4f5
commit 59708bb0f7
1 changed files with 11 additions and 0 deletions
application/clicommands

View File

@ -85,6 +85,17 @@ class WebCommand extends Command
// pcntl_wait($status);
} else {
// child
// Replace console with /dev/null by first freeing the (lowest possible) FDs 0, 1 and 2
// and then opening /dev/null once for every one of them (open(2) chooses the lowest free FD).
fclose(STDIN);
fclose(STDOUT);
fclose(STDERR);
fopen('/dev/null', 'rb');
fopen('/dev/null', 'wb');
fopen('/dev/null', 'wb');
}
}
}