start: don't unconditionally open("/dev/null")

parent 3a8d6b64
...@@ -1287,23 +1287,18 @@ static int do_start(void *data) ...@@ -1287,23 +1287,18 @@ static int do_start(void *data)
close(handler->sigfd); close(handler->sigfd);
if (devnull_fd < 0) { if (handler->conf->console.slave < 0 && handler->backgrounded) {
devnull_fd = open_devnull(); if (devnull_fd < 0) {
devnull_fd = open_devnull();
if (devnull_fd < 0) if (devnull_fd < 0)
goto out_warn_father; goto out_warn_father;
} }
if (handler->conf->console.slave < 0 && handler->backgrounded) ret = set_stdfds(devnull_fd);
if (set_stdfds(devnull_fd) < 0) { if (ret < 0) {
ERROR("Failed to redirect std{in,out,err} to " ERROR("Failed to redirect std{in,out,err} to \"/dev/null\"");
"\"/dev/null\"");
goto out_warn_father; goto out_warn_father;
} }
if (devnull_fd >= 0) {
close(devnull_fd);
devnull_fd = -1;
} }
setsid(); setsid();
......
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