From 6c202c68704b50016c4faba8d6445ab542b5f301 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 24 Jul 1998 12:58:36 +0000 Subject: Update. 1998-07-24 Ulrich Drepper * sysdeps/generic/glob.c (glob): Fix problems with handle tilde. Reported by Brian Wellington . * elf/elf.h: Really define Elf64_Verdef, Elf64_Verdaux, Elf64_Verneed, and Elf64_Vernaux. 1998-07-24 Andreas Jaeger * configure.in: Recognize pgcc as compiler. Reported by sauron@angband.ee.ualberta.ca. 1998-07-02 Thorsten Kukuk * nscd/dbg_log.c: Make sure, that debug message is really written. * nscd/nscd.c: Don't use daemon(), set signal handler after fork. SVID more for gamma(x) with x integer <= 0. --- nscd/nscd.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'nscd/nscd.c') diff --git a/nscd/nscd.c b/nscd/nscd.c index e1c636775f..9ddbb5f54e 100644 --- a/nscd/nscd.c +++ b/nscd/nscd.c @@ -116,11 +116,6 @@ main (int argc, char **argv) exit (EXIT_FAILURE); } - signal (SIGINT, termination_handler); - signal (SIGQUIT, termination_handler); - signal (SIGTERM, termination_handler); - signal (SIGPIPE, SIG_IGN); - /* Check if we are already running. */ if (check_pid (_PATH_NSCDPID)) { @@ -131,14 +126,21 @@ main (int argc, char **argv) /* Behave like a daemon. */ if (go_background) { + int i; + + if (fork ()) + exit (0); + + for (i = 0; i < getdtablesize (); i++) + close (i); + + if (fork ()) + exit (0); + + chdir ("/"); + openlog ("nscd", LOG_CONS | LOG_ODELAY, LOG_DAEMON); - if (daemon (0, 0) < 0) - { - fprintf (stderr, _("connot auto-background: %s\n"), - strerror (errno)); - exit (EXIT_FAILURE); - } if (write_pid (_PATH_NSCDPID) < 0) dbg_log ("%s: %s", _PATH_NSCDPID, strerror (errno)); @@ -147,6 +149,12 @@ main (int argc, char **argv) signal (SIGTTIN, SIG_IGN); signal (SIGTSTP, SIG_IGN); } + + signal (SIGINT, termination_handler); + signal (SIGQUIT, termination_handler); + signal (SIGTERM, termination_handler); + signal (SIGPIPE, SIG_IGN); + /* Cleanup files created by a previous `bind' */ unlink (_PATH_NSCDSOCKET); -- cgit v1.2.3