gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r22568 - gnunet/src/util
Date: Mon, 9 Jul 2012 13:48:43 +0200

Author: grothoff
Date: 2012-07-09 13:48:43 +0200 (Mon, 09 Jul 2012)
New Revision: 22568

Modified:
   gnunet/src/util/os_priority.c
Log:
-reverting SVN 22558 (new insights...)

Modified: gnunet/src/util/os_priority.c
===================================================================
--- gnunet/src/util/os_priority.c       2012-07-09 11:43:59 UTC (rev 22567)
+++ gnunet/src/util/os_priority.c       2012-07-09 11:48:43 UTC (rev 22568)
@@ -961,10 +961,6 @@
   long lRet;
   HANDLE stdin_handle;
   HANDLE stdout_handle;
-  BOOL bresult;
-  DWORD error_code;
-  HANDLE stdih, stdoh, stdeh;
-  DWORD stdif, stdof, stdef;
 
   if (GNUNET_SYSERR == GNUNET_OS_check_helper_binary (filename))
     return NULL; /* not executable */
@@ -1087,7 +1083,8 @@
 
   memset (&start, 0, sizeof (start));
   start.cb = sizeof (start);
-  start.dwFlags |= STARTF_USESTDHANDLES;
+  if ((pipe_stdin != NULL) || (pipe_stdout != NULL))
+    start.dwFlags |= STARTF_USESTDHANDLES;
 
   if (pipe_stdin != NULL)
   {
@@ -1182,54 +1179,24 @@
     return NULL;
   }
 
-  /* Prevents our std handles from being inherited by the child */
-  stdih = GetStdHandle (STD_INPUT_HANDLE);
-  stdoh = GetStdHandle (STD_OUTPUT_HANDLE);
-  stdeh = GetStdHandle (STD_ERROR_HANDLE);
-  if (stdih)
+  if (!CreateProcessW (wpath, wcmd, NULL, NULL, TRUE,
+       DETACHED_PROCESS | CREATE_SUSPENDED, env_block, NULL, &start, &proc))
   {
-    GetHandleInformation (stdih, &stdif);
-    SetHandleInformation (stdih, HANDLE_FLAG_INHERIT, 0);
-  }
-  if (stdoh)
-  {
-    GetHandleInformation (stdoh, &stdof);
-    SetHandleInformation (stdoh, HANDLE_FLAG_INHERIT, 0);
-  }
-  if (stdeh)
-  {
-    GetHandleInformation (stdeh, &stdef);
-    SetHandleInformation (stdeh, HANDLE_FLAG_INHERIT, 0);
-  }
-
-  bresult = CreateProcessW (wpath, wcmd, NULL, NULL, TRUE,
-       DETACHED_PROCESS | CREATE_SUSPENDED, env_block, NULL, &start, &proc);
-  error_code = GetLastError ();
-
-  if (stdih)
-    SetHandleInformation (stdih, stdif, stdif);
-  if (stdoh)
-    SetHandleInformation (stdoh, stdof, stdof);
-  if (stdeh)
-    SetHandleInformation (stdeh, stdef, stdef);
-
-  GNUNET_free (env_block);
-  GNUNET_free (cmd);
-  free (wpath);
-  free (wcmd);
-
-  if (!bresult)
-  {
-    SetErrnoFromWinError (error_code);
+    SetErrnoFromWinError (GetLastError ());
     LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "CreateProcess");
-
     if (NULL != control_pipe)
       GNUNET_DISK_file_close (control_pipe);
     if (NULL != lsocks)
       GNUNET_DISK_pipe_close (lsocks_pipe);
+    GNUNET_free (env_block);
+    GNUNET_free (cmd);
+    free (wpath);
+    free (wcmd);
     return NULL;
   }
 
+  GNUNET_free (env_block);
+
   gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process));
   gnunet_proc->pid = proc.dwProcessId;
   gnunet_proc->handle = proc.hProcess;
@@ -1239,6 +1206,9 @@
 
   ResumeThread (proc.hThread);
   CloseHandle (proc.hThread);
+  GNUNET_free (cmd);
+  free (wpath);
+  free (wcmd);
 
   if (lsocks == NULL || lsocks[0] == INVALID_SOCKET)
     return gnunet_proc;




reply via email to

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