Commit f7cf7499 authored by Simon Kelley's avatar Simon Kelley

Check return code from open()

parent aa300f71
...@@ -561,10 +561,13 @@ int main (int argc, char **argv) ...@@ -561,10 +561,13 @@ 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);
dup2(nullfd, STDOUT_FILENO); if (nullfd != -1)
dup2(nullfd, STDERR_FILENO); {
dup2(nullfd, STDIN_FILENO); dup2(nullfd, STDOUT_FILENO);
close(nullfd); dup2(nullfd, STDERR_FILENO);
dup2(nullfd, STDIN_FILENO);
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. */
......
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