summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Messer <andi@bastelmap.de>2018-01-27 19:34:24 +0100
committerSven Eden <yamakuzure@gmx.net>2018-01-31 15:28:39 +0100
commit6cb78f13ff944c725eb5b0b95fae34308e629057 (patch)
tree3532d63c890ffc17cca9de1718aa89835aaaded2
parent1c1a37c457e3684176eb6d18c2d66ccc64e99a59 (diff)
Close stdin, stdout and stderr on daemonizing
-rw-r--r--src/login/elogind.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/login/elogind.c b/src/login/elogind.c
index d6f2eae..b8ac7d3 100644
--- a/src/login/elogind.c
+++ b/src/login/elogind.c
@@ -125,6 +125,12 @@ static int elogind_daemonize(void) {
/* The first child has to become a new session leader. */
close_all_fds(NULL, 0);
+
+ /* close_all_fds() does not close 0,1,2 */
+ close(0);
+ close(1);
+ close(2);
+
SID = setsid();
if ((pid_t)-1 == SID)
return log_error_errno(errno, "Failed to create new SID: %m");