-doxygen
[oweals/gnunet.git] / src / transport / gnunet-transport-wlan-receiver.c
index 22ad2e20d32fb151ad9babf83f59b4c1ffb45162..b382851234917c26db3af93e40acb87f6b06099c 100644 (file)
@@ -53,7 +53,7 @@ main (int argc, char *argv[])
   /* Setup communication pipeline first */
   if (pipe (commpipe))
   {
-    fprintf (stderr, 
+    fprintf (stderr,
             "Failed to create pipe: %s\n",
             STRERROR (errno));
     exit (1);
@@ -62,8 +62,8 @@ main (int argc, char *argv[])
   /* Attempt to fork and check for errors */
   if ((pid = fork ()) == -1)
   {
-    fprintf (stderr, "Failed to fork: %s\n", 
-            STRERROR (errno));    
+    fprintf (stderr, "Failed to fork: %s\n",
+            STRERROR (errno));
     exit (1);
   }
 
@@ -78,16 +78,19 @@ main (int argc, char *argv[])
     count = 0;
     while (1)
     {
-      ret = read (commpipe[1], msg_buf, sizeof (msg_buf));
+      ret = read (commpipe[0], msg_buf, sizeof (msg_buf));
       if (0 > ret)
+      {
+       fprintf (stderr, "read failed: %s\n", strerror (errno));
        break;
+      }
       count += ret;
       akt = time (NULL);
       if (akt - start > 30)
       {
        bytes_per_s = count / (akt - start);
        bytes_per_s /= 1024;
-       printf ("recv %f kb/s\n", bytes_per_s); 
+       printf ("recv %f kb/s\n", bytes_per_s);
        start = akt;
        count = 0;
       }
@@ -101,7 +104,7 @@ main (int argc, char *argv[])
       fprintf (stderr, "dup2 failed: %s\n", strerror (errno));
     (void) close (commpipe[0]); /* Close unused side of pipe (in side) */
     /* Replace the child fork with a new process */
-    if (execl
+    if (execlp
         ("gnunet-helper-transport-wlan", "gnunet-helper-transport-wlan",
          argv[1], NULL) == -1)
     {