-LRN: fix socket_close logging
[oweals/gnunet.git] / src / util / os_priority.c
index bccde8d4645f53fcfd3398b28c00af274b3243a4..3b3b022b918cfaaa7c222807875bc7fdca2fbac4 100644 (file)
 #include "gnunet_scheduler_lib.h"
 #include "disk.h"
 
+#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
+
+#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util", syscall)
+
+#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename)
+
 #define GNUNET_OS_CONTROL_PIPE "GNUNET_OS_CONTROL_PIPE"
 
 struct GNUNET_OS_Process
@@ -60,32 +66,31 @@ parent_control_handler (void *cls,
   int sig;
 
 #if DEBUG_OS
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "`%s' invoked because of %d\n", __FUNCTION__, tc->reason);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "`%s' invoked because of %d\n", __FUNCTION__,
+       tc->reason);
 #endif
-  if (tc->reason & (GNUNET_SCHEDULER_REASON_SHUTDOWN |
-                    GNUNET_SCHEDULER_REASON_TIMEOUT |
-                    GNUNET_SCHEDULER_REASON_PREREQ_DONE))
+  if (tc->reason &
+      (GNUNET_SCHEDULER_REASON_SHUTDOWN | GNUNET_SCHEDULER_REASON_TIMEOUT |
+       GNUNET_SCHEDULER_REASON_PREREQ_DONE))
   {
     GNUNET_DISK_npipe_close (control_pipe);
   }
   else
   {
-    if (GNUNET_DISK_file_read (control_pipe,
-                               &sig, sizeof (sig)) != sizeof (sig))
+    if (GNUNET_DISK_file_read (control_pipe, &sig, sizeof (sig)) !=
+        sizeof (sig))
     {
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read");
+      LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read");
       GNUNET_DISK_npipe_close (control_pipe);
     }
     else
     {
 #if DEBUG_OS
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Got control code %d from parent\n", sig);
+      LOG (GNUNET_ERROR_TYPE_DEBUG, "Got control code %d from parent\n", sig);
 #endif
       GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                      control_pipe,
-                                      &parent_control_handler, control_pipe);
+                                      control_pipe, &parent_control_handler,
+                                      control_pipe);
       raise (sig);
     }
   }
@@ -106,27 +111,24 @@ GNUNET_OS_install_parent_control_handler (void *cls,
   env_buf = getenv (GNUNET_OS_CONTROL_PIPE);
   if ((env_buf == NULL) || (strlen (env_buf) <= 0))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                _("Not installing a handler because $%s=%s\n"),
-                GNUNET_OS_CONTROL_PIPE, env_buf);
+    LOG (GNUNET_ERROR_TYPE_INFO, _("Not installing a handler because $%s=%s\n"),
+         GNUNET_OS_CONTROL_PIPE, env_buf);
     return;
   }
-  control_pipe = GNUNET_DISK_npipe_open (env_buf,
-                                         GNUNET_DISK_OPEN_READ,
-                                         GNUNET_DISK_PERM_USER_READ |
-                                         GNUNET_DISK_PERM_USER_WRITE);
+  control_pipe =
+      GNUNET_DISK_npipe_open (env_buf, GNUNET_DISK_OPEN_READ,
+                              GNUNET_DISK_PERM_USER_READ |
+                              GNUNET_DISK_PERM_USER_WRITE);
   if (control_pipe == NULL)
   {
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "open", env_buf);
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "open", env_buf);
     return;
   }
 #if DEBUG_OS
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Adding parent control handler pipe `%s' to the scheduler\n",
-              env_buf);
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Adding parent control handler pipe `%s' to the scheduler\n", env_buf);
 #endif
-  GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                  control_pipe,
+  GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, control_pipe,
                                   &parent_control_handler, control_pipe);
 }
 
@@ -166,20 +168,20 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig)
     {
       /* Child process is not controllable via pipe */
 #if DEBUG_OS
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Child process is not controllable, will kill it directly\n");
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "Child process is not controllable, will kill it directly\n");
 #endif
     }
     else if (errno == EPIPE)
     {
 #if DEBUG_OS
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Failed to write into control pipe, because pipe is invalid (the child is most likely dead)\n");
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "Failed to write into control pipe, because pipe is invalid (the child is most likely dead)\n");
 #endif
     }
     else
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  "Failed to write into control pipe , errno is %d\n", errno);
+      LOG (GNUNET_ERROR_TYPE_WARNING,
+           "Failed to write into control pipe , errno is %d\n", errno);
 #if WINDOWS && !defined(__CYGWIN__)
     TerminateProcess (proc->handle, 0);
 #else
@@ -189,8 +191,8 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig)
   else
   {
 #if DEBUG_OS
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Wrote control code into control pipe, now waiting\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Wrote control code into control pipe, now waiting\n");
 #endif
 
 #if WINDOWS
@@ -219,13 +221,14 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig)
      */
     while (1)
     {
-      ret = GNUNET_NETWORK_socket_select (rfds, NULL, efds,
-                                          GNUNET_TIME_relative_multiply
-                                          (GNUNET_TIME_relative_get_unit (),
-                                           5000));
-
-      if (ret < 1 || GNUNET_NETWORK_fdset_handle_isset (efds,
-                                                        proc->control_pipe))
+      ret =
+          GNUNET_NETWORK_socket_select (rfds, NULL, efds,
+                                        GNUNET_TIME_relative_multiply
+                                        (GNUNET_TIME_relative_get_unit (),
+                                         5000));
+
+      if (ret < 1 ||
+          GNUNET_NETWORK_fdset_handle_isset (efds, proc->control_pipe))
       {
         /* Just to be sure */
         PLIBC_KILL (proc->pid, sig);
@@ -234,8 +237,8 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig)
       }
       else
       {
-        if (GNUNET_DISK_file_read (proc->control_pipe, &ret,
-                                   sizeof (ret)) != GNUNET_OK)
+        if (GNUNET_DISK_file_read (proc->control_pipe, &ret, sizeof (ret)) !=
+            GNUNET_OK)
           res = PLIBC_KILL (proc->pid, sig);
 
         /* Child signaled shutdown is in progress */
@@ -394,8 +397,7 @@ GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc,
     errno = 0;
     if ((delta != 0) && (rprio == nice (delta)) && (errno != 0))
     {
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING |
-                           GNUNET_ERROR_TYPE_BULK, "nice");
+      LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, "nice");
       return GNUNET_SYSERR;
     }
   }
@@ -403,15 +405,15 @@ GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc,
   {
     if (0 != setpriority (PRIO_PROCESS, pid, rprio))
     {
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING |
-                           GNUNET_ERROR_TYPE_BULK, "setpriority");
+      LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
+                    "setpriority");
       return GNUNET_SYSERR;
     }
   }
 #else
 #if DEBUG_OS
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
-              "Priority management not availabe for this platform\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
+       "Priority management not availabe for this platform\n");
 #endif
 #endif
   return GNUNET_OK;
@@ -552,10 +554,10 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin,
   int fd_stdin_write;
 
 #if ENABLE_WINDOWS_WORKAROUNDS
-  control_pipe = GNUNET_DISK_npipe_create (&childpipename,
-                                           GNUNET_DISK_OPEN_WRITE,
-                                           GNUNET_DISK_PERM_USER_READ |
-                                           GNUNET_DISK_PERM_USER_WRITE);
+  control_pipe =
+      GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE,
+                                GNUNET_DISK_PERM_USER_READ |
+                                GNUNET_DISK_PERM_USER_WRITE);
   if (control_pipe == NULL)
     return NULL;
 #endif
@@ -593,38 +595,18 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin,
                                        &fd_stdin_write, sizeof (int));
   }
 
-#if HAVE_WORKING_VFORK
-  ret = vfork ();
-#else
   ret = fork ();
-#endif
   if (ret != 0)
   {
     if (ret == -1)
     {
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "fork");
+      LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "fork");
 #if ENABLE_WINDOWS_WORKAROUNDS
       GNUNET_DISK_npipe_close (control_pipe);
 #endif
     }
     else
     {
-
-#if HAVE_WORKING_VFORK
-      /* let's hope vfork actually works; for some extreme cases (including
-       * a testcase) we need 'execvp' to have run before we return, since
-       * we may send a signal to the process next and we don't want it
-       * to be caught by OUR signal handler (but either by the default
-       * handler or the actual handler as installed by the process itself). */
-#else
-      /* let's give the child process a chance to run execvp, 1s should
-       * be plenty in practice */
-      if (pipe_stdout != NULL)
-        GNUNET_DISK_pipe_close_end (pipe_stdout, GNUNET_DISK_PIPE_END_WRITE);
-      if (pipe_stdin != NULL)
-        GNUNET_DISK_pipe_close_end (pipe_stdin, GNUNET_DISK_PIPE_END_READ);
-      sleep (1);
-#endif
       gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process));
       gnunet_proc->pid = ret;
 #if ENABLE_WINDOWS_WORKAROUNDS
@@ -647,7 +629,7 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin,
   {
     GNUNET_break (0 == close (fd_stdout_read));
     if (-1 == dup2 (fd_stdout_write, 1))
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "dup2");
+      LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "dup2");
     GNUNET_break (0 == close (fd_stdout_write));
   }
 
@@ -656,11 +638,11 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin,
 
     GNUNET_break (0 == close (fd_stdin_write));
     if (-1 == dup2 (fd_stdin_read, 0))
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "dup2");
+      LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "dup2");
     GNUNET_break (0 == close (fd_stdin_read));
   }
   execvp (filename, argv);
-  GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "execvp", filename);
+  LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "execvp", filename);
   _exit (1);
 #else
   char *arg;
@@ -722,8 +704,8 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin,
             path, NULL))
   {
     SetErrnoFromWinError (GetLastError ());
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "SearchPath",
-                              non_const_filename);
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "SearchPath",
+                       non_const_filename);
     GNUNET_free (non_const_filename);
     GNUNET_free (pathbuf);
     return NULL;
@@ -776,10 +758,10 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin,
     start.hStdOutput = stdout_handle;
   }
 
-  control_pipe = GNUNET_DISK_npipe_create (&childpipename,
-                                           GNUNET_DISK_OPEN_WRITE,
-                                           GNUNET_DISK_PERM_USER_READ |
-                                           GNUNET_DISK_PERM_USER_WRITE);
+  control_pipe =
+      GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE,
+                                GNUNET_DISK_PERM_USER_READ |
+                                GNUNET_DISK_PERM_USER_WRITE);
   if (control_pipe == NULL)
   {
     GNUNET_free (cmd);
@@ -788,8 +770,8 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin,
   }
 
 #if DEBUG_OS
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Opened the parent end of the pipe `%s'\n", childpipename);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Opened the parent end of the pipe `%s'\n",
+       childpipename);
 #endif
 
   GNUNET_asprintf (&our_env[0], "%s=", GNUNET_OS_CONTROL_PIPE);
@@ -804,7 +786,7 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin,
        env_block, NULL, &start, &proc))
   {
     SetErrnoFromWinError (GetLastError ());
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "CreateProcess", path);
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "CreateProcess", path);
     GNUNET_free (env_block);
     GNUNET_free (cmd);
     return NULL;
@@ -865,8 +847,8 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
  * @return process ID of the new process, -1 on error
  */
 struct GNUNET_OS_Process *
-GNUNET_OS_start_process_v (const int *lsocks,
-                           const char *filename, char *const argv[])
+GNUNET_OS_start_process_v (const int *lsocks, const char *filename,
+                           char *const argv[])
 {
 #if ENABLE_WINDOWS_WORKAROUNDS
   struct GNUNET_DISK_FileHandle *control_pipe = NULL;
@@ -887,10 +869,10 @@ GNUNET_OS_start_process_v (const int *lsocks,
   unsigned int ls;
 
 #if ENABLE_WINDOWS_WORKAROUNDS
-  control_pipe = GNUNET_DISK_npipe_create (&childpipename,
-                                           GNUNET_DISK_OPEN_WRITE,
-                                           GNUNET_DISK_PERM_USER_READ |
-                                           GNUNET_DISK_PERM_USER_WRITE);
+  control_pipe =
+      GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE,
+                                GNUNET_DISK_PERM_USER_READ |
+                                GNUNET_DISK_PERM_USER_WRITE);
   if (control_pipe == NULL)
     return NULL;
 #endif
@@ -904,33 +886,18 @@ GNUNET_OS_start_process_v (const int *lsocks,
       GNUNET_array_append (lscp, ls, k);
     GNUNET_array_append (lscp, ls, -1);
   }
-#if HAVE_WORKING_VFORK
-  ret = vfork ();
-#else
   ret = fork ();
-#endif
   if (ret != 0)
   {
     if (ret == -1)
     {
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "fork");
+      LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "fork");
 #if ENABLE_WINDOWS_WORKAROUNDS
       GNUNET_DISK_npipe_close (control_pipe);
 #endif
     }
     else
     {
-#if HAVE_WORKING_VFORK
-      /* let's hope vfork actually works; for some extreme cases (including
-       * a testcase) we need 'execvp' to have run before we return, since
-       * we may send a signal to the process next and we don't want it
-       * to be caught by OUR signal handler (but either by the default
-       * handler or the actual handler as installed by the process itself). */
-#else
-      /* let's give the child process a chance to run execvp, 1s should
-       * be plenty in practice */
-      sleep (1);
-#endif
       gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process));
       gnunet_proc->pid = ret;
 #if ENABLE_WINDOWS_WORKAROUNDS
@@ -994,7 +961,7 @@ GNUNET_OS_start_process_v (const int *lsocks,
   }
   GNUNET_array_grow (lscp, ls, 0);
   execvp (filename, argv);
-  GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "execvp", filename);
+  LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "execvp", filename);
   _exit (1);
 #else
   char **arg, **non_const_argv;
@@ -1062,8 +1029,8 @@ GNUNET_OS_start_process_v (const int *lsocks,
             path, NULL))
   {
     SetErrnoFromWinError (GetLastError ());
-    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "SearchPath",
-                              non_const_filename);
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "SearchPath",
+                       non_const_filename);
     GNUNET_free (non_const_filename);
     GNUNET_free (pathbuf);
     return NULL;
@@ -1121,10 +1088,10 @@ GNUNET_OS_start_process_v (const int *lsocks,
   memset (&start, 0, sizeof (start));
   start.cb = sizeof (start);
 
-  control_pipe = GNUNET_DISK_npipe_create (&childpipename,
-                                           GNUNET_DISK_OPEN_WRITE,
-                                           GNUNET_DISK_PERM_USER_READ |
-                                           GNUNET_DISK_PERM_USER_WRITE);
+  control_pipe =
+      GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE,
+                                GNUNET_DISK_PERM_USER_READ |
+                                GNUNET_DISK_PERM_USER_WRITE);
   if (control_pipe == NULL)
   {
     GNUNET_free (cmd);
@@ -1133,8 +1100,8 @@ GNUNET_OS_start_process_v (const int *lsocks,
   }
 
 #if DEBUG_OS
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Opened the parent end of the pipe `%s'\n", childpipename);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Opened the parent end of the pipe `%s'\n",
+       childpipename);
 #endif
 
   GNUNET_asprintf (&our_env[0], "%s=", GNUNET_OS_CONTROL_PIPE);
@@ -1149,7 +1116,7 @@ GNUNET_OS_start_process_v (const int *lsocks,
        env_block, NULL, &start, &proc))
   {
     SetErrnoFromWinError (GetLastError ());
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "CreateProcess");
+    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "CreateProcess");
     GNUNET_free (env_block);
     GNUNET_free (cmd);
     return NULL;
@@ -1193,7 +1160,7 @@ GNUNET_OS_process_status (struct GNUNET_OS_Process *proc,
   ret = waitpid (proc->pid, &status, WNOHANG);
   if (ret < 0)
   {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
+    LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "waitpid");
     return GNUNET_SYSERR;
   }
   if (0 == ret)
@@ -1204,7 +1171,7 @@ GNUNET_OS_process_status (struct GNUNET_OS_Process *proc,
   }
   if (proc->pid != ret)
   {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
+    LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "waitpid");
     return GNUNET_SYSERR;
   }
   if (WIFEXITED (status))
@@ -1242,8 +1209,8 @@ GNUNET_OS_process_status (struct GNUNET_OS_Process *proc,
   ret = proc->pid;
   if (h == NULL || ret == 0)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Invalid process information {%d, %08X}\n", ret, h);
+    LOG (GNUNET_ERROR_TYPE_WARNING, "Invalid process information {%d, %08X}\n",
+         ret, h);
     return GNUNET_SYSERR;
   }
   if (h == NULL)
@@ -1255,7 +1222,7 @@ GNUNET_OS_process_status (struct GNUNET_OS_Process *proc,
   if (ret == 0 || error_code != NO_ERROR)
   {
     SetErrnoFromWinError (error_code);
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "GetExitCodeProcess");
+    LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "GetExitCodeProcess");
     return GNUNET_SYSERR;
   }
   if (STILL_ACTIVE == c)
@@ -1294,8 +1261,8 @@ GNUNET_OS_process_wait (struct GNUNET_OS_Process *proc)
   h = proc->handle;
   if (NULL == h)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Invalid process information {%d, %08X}\n", proc->pid, h);
+    LOG (GNUNET_ERROR_TYPE_WARNING, "Invalid process information {%d, %08X}\n",
+         proc->pid, h);
     return GNUNET_SYSERR;
   }
   if (h == NULL)
@@ -1414,9 +1381,9 @@ cmd_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     proc (cmd->proc_cls, NULL);
     return;
   }
-  ret = GNUNET_DISK_file_read (cmd->r,
-                               &cmd->buf[cmd->off],
-                               sizeof (cmd->buf) - cmd->off);
+  ret =
+      GNUNET_DISK_file_read (cmd->r, &cmd->buf[cmd->off],
+                             sizeof (cmd->buf) - cmd->off);
   if (ret <= 0)
   {
     if ((cmd->off > 0) && (cmd->off < sizeof (cmd->buf)))
@@ -1457,10 +1424,9 @@ cmd_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  * @return NULL on error
  */
 struct GNUNET_OS_CommandHandle *
-GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc,
-                       void *proc_cls,
-                       struct GNUNET_TIME_Relative timeout,
-                       const char *binary, ...)
+GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc, void *proc_cls,
+                       struct GNUNET_TIME_Relative timeout, const char *binary,
+                       ...)
 {
   struct GNUNET_OS_CommandHandle *cmd;
   struct GNUNET_OS_Process *eip;