- err("open /dev/null failed");
- if (outpipe[1] > 0)
- dup2(outpipe[1], STDOUT_FILENO);
- if (errpipe[1] > 0)
- dup2(errpipe[1], STDERR_FILENO);
+ err("open /dev/null failed: %s", strerror(errno));
+ if (outpipe[WRITE_END] > 0) {
+ dup2(outpipe[WRITE_END], STDOUT_FILENO);
+ close(outpipe[WRITE_END]);
+ }
+ if (errpipe[WRITE_END] > 0) {
+ dup2(errpipe[WRITE_END], STDERR_FILENO);
+ close(errpipe[WRITE_END]);
+ }