-fixes
[oweals/gnunet.git] / src / util / os_priority.c
index 4f3c5e62209f1e78b54d456ae84ab16e5e5cdf40..0b56ce5c520e2929be58e0f014c7ff592a1f6add 100644 (file)
@@ -326,6 +326,7 @@ parent_control_handler (void *cls,
 {
   struct GNUNET_DISK_FileHandle *control_pipe = cls;
   char sig;
+  ssize_t ret;
   
   LOG (GNUNET_ERROR_TYPE_DEBUG, "`%s' invoked because of %d\n", __FUNCTION__,
        tc->reason);
@@ -336,10 +337,11 @@ parent_control_handler (void *cls,
     GNUNET_DISK_file_close (control_pipe);
     return;
   }
-  if (GNUNET_DISK_file_read (control_pipe, &sig, sizeof (sig)) !=
-      sizeof (sig))
+  ret = GNUNET_DISK_file_read (control_pipe, &sig, sizeof (sig));
+  if (sizeof (sig) != ret)
   {
-    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read");
+    if (-1 == ret)
+      LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read");
     GNUNET_DISK_file_close (control_pipe);
     return;
   }
@@ -434,20 +436,13 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig)
     proc->control_pipe = npipe_open (proc->childpipename,
                                     GNUNET_DISK_OPEN_WRITE);
 #endif
-  if (NULL == proc->control_pipe)
+  if (NULL != proc->control_pipe)
   {
-#if WINDOWS
-    /* no pipe and windows? can't do this */
-    errno = EINVAL;
-    return -1;
-#else
-    return kill (proc->pid, sig);
-#endif    
+    ret = GNUNET_DISK_file_write (proc->control_pipe, &csig, sizeof (csig));
+    if (ret == sizeof (csig))  
+      return 0;
   }
-  ret = GNUNET_DISK_file_write (proc->control_pipe, &csig, sizeof (csig));
-  if (ret == sizeof (csig))  
-    return 0;
-  /* pipe failed, try other methods */
+  /* pipe failed or non-existent, try other methods */
   switch (sig)
   {
 #if !WINDOWS
@@ -471,7 +466,7 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig)
     errno = EINVAL;
     return -1;
 #else
-    return kill (proc->pid, sig);
+    return PLIBC_KILL (proc->pid, sig);
 #endif    
   }
 }