Commit f7cf7499 authored by Simon Kelley's avatar Simon Kelley

Check return code from open()

parent aa300f71
...@@ -561,11 +561,14 @@ int main (int argc, char **argv) ...@@ -561,11 +561,14 @@ int main (int argc, char **argv)
{ {
/* open stdout etc to /dev/null */ /* open stdout etc to /dev/null */
int nullfd = open("/dev/null", O_RDWR); int nullfd = open("/dev/null", O_RDWR);
if (nullfd != -1)
{
dup2(nullfd, STDOUT_FILENO); dup2(nullfd, STDOUT_FILENO);
dup2(nullfd, STDERR_FILENO); dup2(nullfd, STDERR_FILENO);
dup2(nullfd, STDIN_FILENO); dup2(nullfd, STDIN_FILENO);
close(nullfd); close(nullfd);
} }
}
/* if we are to run scripts, we need to fork a helper before dropping root. */ /* if we are to run scripts, we need to fork a helper before dropping root. */
daemon->helperfd = -1; daemon->helperfd = -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment