summary refs log tree commit diff
path: root/nscd
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-02-21 01:57:26 +0000
committerUlrich Drepper <drepper@redhat.com>2004-02-21 01:57:26 +0000
commit230c3e1e54e0a997ce70e110e0f423955bd4701b (patch)
tree25b77a7954afb0e8cfac4ecc2bf27c8183fec0ac /nscd
parenta461b14777bc56a19d3252d7fa5b47ee598757a0 (diff)
downloadglibc-230c3e1e54e0a997ce70e110e0f423955bd4701b.tar.gz
glibc-230c3e1e54e0a997ce70e110e0f423955bd4701b.tar.xz
glibc-230c3e1e54e0a997ce70e110e0f423955bd4701b.zip
Update.
2004-02-20  Thorsten Kukuk  <kukuk@suse.de>

	* nscd/nscd.c (termination_handler): Use _exit instead of exit

	* nscd/nscd.c (main): Report fork errors.
Diffstat (limited to 'nscd')
-rw-r--r--nscd/nscd.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/nscd/nscd.c b/nscd/nscd.c
index 50d3cfcf5f..e3040bb20f 100644
--- a/nscd/nscd.c
+++ b/nscd/nscd.c
@@ -159,7 +159,10 @@ main (int argc, char **argv)
     {
       int i;
 
-      if (fork ())
+      pid_t pid = fork ();
+      if (pid == -1)
+	error (EXIT_FAILURE, errno, _("cannot fork"));
+      if (pid != 0)
 	exit (0);
 
       int nullfd = open (_PATH_DEVNULL, O_RDWR);
@@ -211,7 +214,10 @@ main (int argc, char **argv)
 	for (i = min_close_fd; i < getdtablesize (); i++)
 	  close (i);
 
-      if (fork ())
+      pid = fork ();
+      if (pid == -1)
+	error (EXIT_FAILURE, errno, _("cannot fork"));
+      if (pid != 0)
 	exit (0);
 
       setsid ();
@@ -237,7 +243,7 @@ main (int argc, char **argv)
   signal (SIGTERM, termination_handler);
   signal (SIGPIPE, SIG_IGN);
 
-  /* Cleanup files created by a previous `bind'.  */
+  /* Cleanup files created by a previous 'bind'.  */
   unlink (_PATH_NSCDSOCKET);
 
   /* Make sure we do not get recursive calls.  */
@@ -394,13 +400,13 @@ termination_handler (int signum)
 {
   close_sockets ();
 
-  /* Clean up the file created by `bind'.  */
+  /* Clean up the file created by 'bind'.  */
   unlink (_PATH_NSCDSOCKET);
 
   /* Clean up pid file.  */
   unlink (_PATH_NSCDPID);
 
-  exit (EXIT_SUCCESS);
+  _exit (EXIT_SUCCESS);
 }
 
 /* Returns 1 if the process in pid file FILE is running, 0 if not.  */