launch_daemon: Open stdin/out/err FDs.
* As with the boot script, point them to /dev/null. * This should fix #12298.
This commit is contained in:
@@ -1291,9 +1291,25 @@ LaunchDaemon::_AddInitJob(BJob* job)
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
open_stdio(int targetFD, int openMode)
|
||||||
|
{
|
||||||
|
int fd = open("/dev/null", openMode);
|
||||||
|
if (fd != targetFD) {
|
||||||
|
dup2(fd, targetFD);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
|
// Make stdin/out/err available
|
||||||
|
open_stdio(STDIN_FILENO, O_RDONLY);
|
||||||
|
open_stdio(STDOUT_FILENO, O_WRONLY);
|
||||||
|
dup2(STDOUT_FILENO, STDERR_FILENO);
|
||||||
|
|
||||||
EventMap events;
|
EventMap events;
|
||||||
status_t status;
|
status_t status;
|
||||||
LaunchDaemon* daemon = new LaunchDaemon(false, events, status);
|
LaunchDaemon* daemon = new LaunchDaemon(false, events, status);
|
||||||
|
|||||||
Reference in New Issue
Block a user