gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r17996 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r17996 - gnunet/src/transport
Date: Fri, 4 Nov 2011 14:52:33 +0100

Author: grothoff
Date: 2011-11-04 14:52:33 +0100 (Fri, 04 Nov 2011)
New Revision: 17996

Modified:
   gnunet/src/transport/gnunet_wlan_sender.c
Log:
close stdin before dup-ing, check return value of dup2

Modified: gnunet/src/transport/gnunet_wlan_sender.c
===================================================================
--- gnunet/src/transport/gnunet_wlan_sender.c   2011-11-04 13:50:14 UTC (rev 
17995)
+++ gnunet/src/transport/gnunet_wlan_sender.c   2011-11-04 13:52:33 UTC (rev 
17996)
@@ -30,6 +30,7 @@
 #include <netinet/in.h>
 #include <string.h>
 #include <time.h>
+#include <errno.h>
 #include "gnunet_protocols.h"
 #include "plugin_transport_wlan.h"
 
@@ -216,13 +217,18 @@
        }
        else{
                /* A zero PID indicates that this is the child process */
-               dup2(commpipe[0],0);    /* Replace stdin with the in side of 
the pipe */
-               close(commpipe[1]);             /* Close unused side of pipe 
(out side) */
+               (void) close(0);
+               if (-1 == dup2(commpipe[0],0))  /* Replace stdin with the in 
side of the pipe */
+                 fprintf (stderr,
+                          "dup2 failed: %s\n",
+                          strerror (errno));
+               (void) close(commpipe[1]);              /* Close unused side of 
pipe (out side) */
                /* Replace the child fork with a new process */
-               
if(execl("gnunet-transport-wlan-helper","gnunet-transport-wlan-helper", 
argv[1], NULL) == -1){
-                       fprintf(stderr,"Could not start 
gnunet-transport-wlan-helper!");
-                       exit(1);
-               }
+               if 
(execl("gnunet-transport-wlan-helper","gnunet-transport-wlan-helper", argv[1], 
NULL) == -1)
+                 {
+                   fprintf(stderr,"Could not start 
gnunet-transport-wlan-helper!");
+                   _exit(1);
+                 }
        }
        return 0;
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]