From: Andreas Messer Date: Sat, 27 Jan 2018 18:34:24 +0000 (+0100) Subject: Close stdin, stdout and stderr on daemonizing X-Git-Tag: v235.3~15 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=6cb78f13ff944c725eb5b0b95fae34308e629057;p=elogind.git Close stdin, stdout and stderr on daemonizing --- diff --git a/src/login/elogind.c b/src/login/elogind.c index d6f2eaef4..b8ac7d367 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");