do not leak nullfd
authorChristian Grothoff <christian@grothoff.org>
Sat, 14 Aug 2010 21:36:08 +0000 (21:36 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sat, 14 Aug 2010 21:36:08 +0000 (21:36 +0000)
src/util/service.c

index 21841dd49c6ad2d79fc89f302c75e81b0113e535..df5342c1dca496161ab58e60231ebfd09fa9c974 100644 (file)
@@ -1415,10 +1415,12 @@ detach_terminal (struct GNUNET_SERVICE_Context *sctx)
     return GNUNET_SYSERR;
   /* set stdin/stdout to /dev/null */
   if ((dup2 (nullfd, 0) < 0) || (dup2 (nullfd, 1) < 0))
-    {
+    {      
       GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "dup2");
+      (void) CLOSE (nullfd);
       return GNUNET_SYSERR;
     }
+  (void) CLOSE (nullfd);
   /* Detach from controlling terminal */
   pid = setsid ();
   if (pid == -1)