When logging to stdout/stderr don't close those descriptors after fork().
MFC after: 2 weeks Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com
This commit is contained in:
parent
3f828c18e5
commit
e64887c4d6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=211884
@ -61,8 +61,21 @@ descriptors(void)
|
|||||||
pjdlog_errno(LOG_WARNING, "sysconf(_SC_OPEN_MAX) failed");
|
pjdlog_errno(LOG_WARNING, "sysconf(_SC_OPEN_MAX) failed");
|
||||||
maxfd = 1024;
|
maxfd = 1024;
|
||||||
}
|
}
|
||||||
for (fd = 0; fd <= maxfd; fd++)
|
for (fd = 0; fd <= maxfd; fd++) {
|
||||||
close(fd);
|
switch (fd) {
|
||||||
|
case STDIN_FILENO:
|
||||||
|
case STDOUT_FILENO:
|
||||||
|
case STDERR_FILENO:
|
||||||
|
if (pjdlog_mode_get() == PJDLOG_MODE_STD)
|
||||||
|
break;
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
default:
|
||||||
|
close(fd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pjdlog_mode_get() == PJDLOG_MODE_STD)
|
||||||
|
return;
|
||||||
/*
|
/*
|
||||||
* Redirect stdin, stdout and stderr to /dev/null.
|
* Redirect stdin, stdout and stderr to /dev/null.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user