Signed-off-by: Kay Sievers <kay.sievers@suse.de>
/* discard child output or connect to pipe */
devnull = open("/dev/null", O_RDWR);
/* discard child output or connect to pipe */
devnull = open("/dev/null", O_RDWR);
+ if (devnull > 0) {
+ dup2(devnull, STDIN_FILENO);
+ if (outpipe[1] < 0)
+ dup2(devnull, STDOUT_FILENO);
+ if (errpipe[1] < 0)
+ dup2(devnull, STDERR_FILENO);
+ close(devnull);
+ } else
err("open /dev/null failed");
err("open /dev/null failed");
- exit(1);
- }
- dup2(devnull, STDIN_FILENO);
-
if (outpipe[1] > 0)
dup2(outpipe[1], STDOUT_FILENO);
if (outpipe[1] > 0)
dup2(outpipe[1], STDOUT_FILENO);
- else
- dup2(devnull, STDOUT_FILENO);
-
if (errpipe[1] > 0)
dup2(errpipe[1], STDERR_FILENO);
if (errpipe[1] > 0)
dup2(errpipe[1], STDERR_FILENO);
- else
- dup2(devnull, STDERR_FILENO);
-
- close(devnull);
execv(arg, argv);
/* we should never reach this */
execv(arg, argv);
/* we should never reach this */
{
int maxsockplus;
int retval;
{
int maxsockplus;
int retval;
struct sigaction act;
fd_set readfds;
const char *value;
struct sigaction act;
fd_set readfds;
const char *value;
setpriority(PRIO_PROCESS, 0, UDEVD_PRIORITY);
/* Set fds to dev/null */
setpriority(PRIO_PROCESS, 0, UDEVD_PRIORITY);
/* Set fds to dev/null */
- fd = open( "/dev/null", O_RDWR );
- if (fd >= 0) {
- dup2(fd, STDIN_FILENO);
- dup2(fd, STDOUT_FILENO);
- dup2(fd, STDERR_FILENO);
- close(fd);
+ devnull = open( "/dev/null", O_RDWR );
+ if (devnull > 0) {
+ dup2(devnull, STDIN_FILENO);
+ dup2(devnull, STDOUT_FILENO);
+ dup2(devnull, STDERR_FILENO);
+ close(devnull);
} else
err("error opening /dev/null %s", strerror(errno));
} else
err("error opening /dev/null %s", strerror(errno));