diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2009-12-14 12:00:32 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-12-15 08:33:56 -0500 |
commit | 850d250442aaae413c054cf8136506e8d90f2fbe (patch) | |
tree | e76bfa5b0a71f05c9e5920b07549fe32f76ea3bc /server/util/server.c | |
parent | 03bf008c95a64a1c7440b9feb7ff2a647303f6f3 (diff) | |
download | sssd-850d250442aaae413c054cf8136506e8d90f2fbe.tar.gz sssd-850d250442aaae413c054cf8136506e8d90f2fbe.tar.bz2 sssd-850d250442aaae413c054cf8136506e8d90f2fbe.zip |
Properly close STDERR when daemonizing
This is necessary so that any process managing our startup and
shutdown (e.g. authconfig) does not block and stall waiting for
stderr to terminate.
Fixes bug https://fedorahosted.org/sssd/ticket/324
Diffstat (limited to 'server/util/server.c')
-rw-r--r-- | server/util/server.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/server/util/server.c b/server/util/server.c index 977deaeb..e8d26dcf 100644 --- a/server/util/server.c +++ b/server/util/server.c @@ -39,7 +39,7 @@ /******************************************************************* Close the low 3 fd's and open dev/null in their place. ********************************************************************/ -static void close_low_fds(bool stderr_too) +static void close_low_fds() { #ifndef VALGRIND int fd; @@ -47,16 +47,11 @@ static void close_low_fds(bool stderr_too) close(0); close(1); - - if (stderr_too) - close(2); + close(2); /* try and use up these file descriptors, so silly library routines writing to stdout etc won't cause havoc */ for (i=0;i<3;i++) { - if (i == 2 && !stderr_too) - continue; - fd = open("/dev/null",O_RDWR,0); if (fd < 0) fd = open("/dev/null",O_WRONLY,0); @@ -99,8 +94,7 @@ void become_daemon(bool Fork) } /* Close fd's 0,1,2. Needed if started by rsh */ - close_low_fds(false); /* Don't close stderr, let the debug system - attach it to the logfile */ + close_low_fds(); } int pidfile(const char *path, const char *name) |