aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-04 13:52:33 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-04 13:52:33 +0000
commitea9a077ced7eac09a3a6813428aad7e0395f966d (patch)
tree3be62bf400657291f6658651da77bdde194a88ad /src/transport
parentacac5d115545c45196f27077769b9d84e75926f1 (diff)
downloadgnunet-ea9a077ced7eac09a3a6813428aad7e0395f966d.tar.gz
gnunet-ea9a077ced7eac09a3a6813428aad7e0395f966d.zip
close stdin before dup-ing, check return value of dup2
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet_wlan_sender.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/transport/gnunet_wlan_sender.c b/src/transport/gnunet_wlan_sender.c
index 89bfa0820..3aa32fb1c 100644
--- a/src/transport/gnunet_wlan_sender.c
+++ b/src/transport/gnunet_wlan_sender.c
@@ -30,6 +30,7 @@
30#include <netinet/in.h> 30#include <netinet/in.h>
31#include <string.h> 31#include <string.h>
32#include <time.h> 32#include <time.h>
33#include <errno.h>
33#include "gnunet_protocols.h" 34#include "gnunet_protocols.h"
34#include "plugin_transport_wlan.h" 35#include "plugin_transport_wlan.h"
35 36
@@ -216,13 +217,18 @@ int main(int argc, char *argv[]){
216 } 217 }
217 else{ 218 else{
218 /* A zero PID indicates that this is the child process */ 219 /* A zero PID indicates that this is the child process */
219 dup2(commpipe[0],0); /* Replace stdin with the in side of the pipe */ 220 (void) close(0);
220 close(commpipe[1]); /* Close unused side of pipe (out side) */ 221 if (-1 == dup2(commpipe[0],0)) /* Replace stdin with the in side of the pipe */
222 fprintf (stderr,
223 "dup2 failed: %s\n",
224 strerror (errno));
225 (void) close(commpipe[1]); /* Close unused side of pipe (out side) */
221 /* Replace the child fork with a new process */ 226 /* Replace the child fork with a new process */
222 if(execl("gnunet-transport-wlan-helper","gnunet-transport-wlan-helper", argv[1], NULL) == -1){ 227 if (execl("gnunet-transport-wlan-helper","gnunet-transport-wlan-helper", argv[1], NULL) == -1)
223 fprintf(stderr,"Could not start gnunet-transport-wlan-helper!"); 228 {
224 exit(1); 229 fprintf(stderr,"Could not start gnunet-transport-wlan-helper!");
225 } 230 _exit(1);
231 }
226 } 232 }
227 return 0; 233 return 0;
228} 234}