summaryrefslogtreecommitdiff
path: root/udev_utils_run.c
diff options
context:
space:
mode:
Diffstat (limited to 'udev_utils_run.c')
-rw-r--r--udev_utils_run.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/udev_utils_run.c b/udev_utils_run.c
index 44fb7f8316..cf633661e4 100644
--- a/udev_utils_run.c
+++ b/udev_utils_run.c
@@ -136,23 +136,19 @@ int run_program(const char *command, const char *subsystem,
/* discard child output or connect to pipe */
devnull = open("/dev/null", O_RDWR);
- if (devnull < 0) {
+ 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");
- exit(1);
- }
- dup2(devnull, STDIN_FILENO);
-
if (outpipe[1] > 0)
dup2(outpipe[1], STDOUT_FILENO);
- else
- dup2(devnull, STDOUT_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 */