summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-12-14 12:00:32 -0500
committerStephen Gallagher <sgallagh@redhat.com>2009-12-15 07:23:57 -0500
commit663f026107822b2b9acb0d35a82d66d4fc816abd (patch)
treeab34bf9b27c23b85b7bdcae0255f30a7d5eb4fdd /server
parent38d9300d424d367f08c29fa9d194a0e999fd5c13 (diff)
downloadsssd-663f026107822b2b9acb0d35a82d66d4fc816abd.tar.gz
sssd-663f026107822b2b9acb0d35a82d66d4fc816abd.tar.xz
sssd-663f026107822b2b9acb0d35a82d66d4fc816abd.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')
-rw-r--r--server/util/server.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/server/util/server.c b/server/util/server.c
index 977deaeb2..e8d26dcf0 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)