diff options
author | William Hubbs <w.d.hubbs@gmail.com> | 2015-04-24 11:20:26 -0500 |
---|---|---|
committer | William Hubbs <w.d.hubbs@gmail.com> | 2015-04-24 12:24:09 -0500 |
commit | 03803ae8e966755e8bf6d52b61209792cb830cf4 (patch) | |
tree | a328b8baca6df3572a2fe93a6a5b2890da0d251d /src | |
parent | 1c2f7bf607ee7e24dca0a2710cef9e9b24e819f7 (diff) |
start-stop-daemon: redirect stdin if --background option is used
X-Gentoo-Bug: 498684
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=498684
Diffstat (limited to 'src')
-rw-r--r-- | src/rc/start-stop-daemon.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index 7919835b..7d2aba37 100644 --- a/src/rc/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c @@ -678,6 +678,7 @@ start_stop_daemon(int argc, char **argv) int tid = 0; char *redirect_stderr = NULL; char *redirect_stdout = NULL; + int stdin_fd; int stdout_fd; int stderr_fd; pid_t pid, spid; @@ -1247,6 +1248,7 @@ start_stop_daemon(int argc, char **argv) setenv("PATH", newpath, 1); } + stdin_fd = devnull_fd; stdout_fd = devnull_fd; stderr_fd = devnull_fd; if (redirect_stdout) { @@ -1266,7 +1268,8 @@ start_stop_daemon(int argc, char **argv) applet, redirect_stderr, strerror(errno)); } - /* We don't redirect stdin as some daemons may need it */ + if (background) + dup2(stdin_fd, STDIN_FILENO); if (background || redirect_stdout || rc_yesno(getenv("EINFO_QUIET"))) dup2(stdout_fd, STDOUT_FILENO); if (background || redirect_stderr || rc_yesno(getenv("EINFO_QUIET"))) |