commit: 03803ae8e966755e8bf6d52b61209792cb830cf4 Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com> AuthorDate: Fri Apr 24 16:20:26 2015 +0000 Commit: William Hubbs <williamh <AT> gentoo <DOT> org> CommitDate: Fri Apr 24 17:24:09 2015 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=03803ae8
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 src/rc/start-stop-daemon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index 7919835..7d2aba3 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")))