summaryrefslogtreecommitdiffstats
path: root/cmd/zed/zed_exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/zed/zed_exec.c')
-rwxr-xr-x[-rw-r--r--]cmd/zed/zed_exec.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/cmd/zed/zed_exec.c b/cmd/zed/zed_exec.c
index 1d040ccd5..1a3b76d07 100644..100755
--- a/cmd/zed/zed_exec.c
+++ b/cmd/zed/zed_exec.c
@@ -106,10 +106,11 @@ _zed_exec_fork_child(uint64_t eid, const char *dir, const char *prog,
return;
} else if (pid == 0) {
(void) umask(022);
- fd = open("/dev/null", O_RDWR);
- (void) dup2(fd, STDIN_FILENO);
- (void) dup2(fd, STDOUT_FILENO);
- (void) dup2(fd, STDERR_FILENO);
+ if ((fd = open("/dev/null", O_RDWR)) != -1) {
+ (void) dup2(fd, STDIN_FILENO);
+ (void) dup2(fd, STDOUT_FILENO);
+ (void) dup2(fd, STDERR_FILENO);
+ }
(void) dup2(zfd, ZEVENT_FILENO);
zed_file_close_from(ZEVENT_FILENO + 1);
execle(path, prog, NULL, env);