gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r12994 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r12994 - gnunet/src/util
Date: Wed, 15 Sep 2010 10:46:57 +0200

Author: wachs
Date: 2010-09-15 10:46:57 +0200 (Wed, 15 Sep 2010)
New Revision: 12994

Modified:
   gnunet/src/util/os_priority.c
Log:
0001602: A patch to fix process spawning with redirected std streams 


Modified: gnunet/src/util/os_priority.c
===================================================================
--- gnunet/src/util/os_priority.c       2010-09-15 08:32:00 UTC (rev 12993)
+++ gnunet/src/util/os_priority.c       2010-09-15 08:46:57 UTC (rev 12994)
@@ -255,13 +255,13 @@
   char *arg;
   unsigned int cmdlen;
   char *cmd, *idx;
+  int findresult;
   STARTUPINFO start;
   PROCESS_INFORMATION proc;
-#if NILS
+
   HANDLE stdin_handle;
   HANDLE stdout_handle;
-#endif
-  char *fn = NULL;
+
   char path[MAX_PATH + 1];
 
   cmdlen = 0;
@@ -270,7 +270,7 @@
       cmdlen = cmdlen + strlen (arg) + 3;
   va_end (ap);
 
-  cmd = idx = GNUNET_malloc (sizeof (char) * cmdlen);
+  cmd = idx = GNUNET_malloc (sizeof (char) * (cmdlen + 1));
   va_start (ap, filename);
   while (NULL != (arg = va_arg (ap, char *)))
       idx += sprintf (idx, "\"%s\" ", arg);
@@ -279,7 +279,6 @@
   memset (&start, 0, sizeof (start));
   start.cb = sizeof (start);
 
-#if NILS
   if ((pipe_stdin != NULL) || (pipe_stdout != NULL))
     start.dwFlags |= STARTF_USESTDHANDLES;
 
@@ -294,27 +293,26 @@
       GNUNET_DISK_internal_file_handle_ (GNUNET_DISK_pipe_handle(pipe_stdout, 
GNUNET_DISK_PIPE_END_WRITE), &stdout_handle, sizeof (HANDLE));
       start.hStdOutput = stdout_handle;
     }
-#endif
-  if ((int) FindExecutable(filename, NULL, path) <= 32) 
+
+  findresult = (int) FindExecutableA (filename, NULL, path);
+  if (findresult <= 32) 
     {
       SetErrnoFromWinError (GetLastError ());
-      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "FindExecutable", fn);
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "FindExecutable", 
filename);
       return -1;
     }
 
-  if (!CreateProcess
-      (path, cmd, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &start,
+  if (!CreateProcessA
+      (path, cmd, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &start,
        &proc))
     {
       SetErrnoFromWinError (GetLastError ());
-      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "CreateProcess", fn);
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "CreateProcess", 
path);
       return -1;
     }
 
   CreateThread (NULL, 64000, ChildWaitThread, proc.hProcess, 0, NULL);
 
-  if (fn != filename)
-    GNUNET_free (fn);
   CloseHandle (proc.hThread);
 
   GNUNET_free (cmd);




reply via email to

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