[projects/rc-scripts] daemon: always close stdin, avoids weird program deaths; redirect stdin "in", not "out"

glen glen at pld-linux.org
Sun Mar 2 11:03:39 CET 2014


commit 289e29826cf1ce827e69ad3b6af8d2d9933bc875
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sun Mar 2 02:40:52 2014 +0200

    daemon: always close stdin, avoids weird program deaths; redirect stdin "in", not "out"

 lib/functions | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/lib/functions b/lib/functions
index 56cab80..e75f61d 100644
--- a/lib/functions
+++ b/lib/functions
@@ -726,13 +726,14 @@ daemon() {
 		if [ "$closefds" = 1 ]; then
 			exec 1>&-
 			exec 2>&-
-			exec 0>&-
+			exec 0<&-
 		elif [ "$redirfds" = 1 ]; then
 			exec 1>/dev/null
 			exec 2>/dev/null
-			exec 0>/dev/null
+			exec 0</dev/null
 		else
 			exec 2>&1
+			exec 0</dev/null
 		fi
 
 		if is_no "$RC_LOGGING"; then
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/rc-scripts.git/commitdiff/289e29826cf1ce827e69ad3b6af8d2d9933bc875



More information about the pld-cvs-commit mailing list