From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 006A5138CA4 for ; Fri, 24 Apr 2015 18:13:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A0224E0807; Fri, 24 Apr 2015 18:13:09 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5BD89E0807 for ; Fri, 24 Apr 2015 18:13:09 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 493883409AE for ; Fri, 24 Apr 2015 18:13:08 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id D538B16A70 for ; Fri, 24 Apr 2015 18:13:04 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1429896249.03803ae8e966755e8bf6d52b61209792cb830cf4.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/ X-VCS-Repository: proj/openrc X-VCS-Files: src/rc/start-stop-daemon.c X-VCS-Directories: src/rc/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 03803ae8e966755e8bf6d52b61209792cb830cf4 X-VCS-Branch: master Date: Fri, 24 Apr 2015 18:13:04 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: e3ed36fd-ee1d-4e50-8ee9-a904237ea693 X-Archives-Hash: a3a013d86fc001481a298264ca6d5162 commit: 03803ae8e966755e8bf6d52b61209792cb830cf4 Author: William Hubbs gmail com> AuthorDate: Fri Apr 24 16:20:26 2015 +0000 Commit: William Hubbs gentoo 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")))