wcmd woes

Eric Pouech pouech-eric at wanadoo.fr
Wed Aug 27 13:51:00 CDT 2003


This patch is a merge from:
1/ a left over submission from Oleg Prokhorov
2/ another fix in the same area
will those two patches, wcmd behavior regarding io handles inheritance 
in process creation is cleaner
this fixes #1604

A+
-- 
Eric Pouech
-------------- next part --------------
Name:          wc_inh
ChangeLog:     
Oleg Prokhorov <xolegpro at rbcmail.ru>:
	- No handles were inherited in CreateProcess, all child console programs were silent
Eric Pouech:
	- Ensure redirected stream handle for child process are actually inheritable.
License:       X11
GenDate:       2003/08/27 18:48:25 UTC
ModifiedFiles: programs/wcmd/wcmdmain.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/wcmd/wcmdmain.c,v
retrieving revision 1.34
diff -u -u -r1.34 wcmdmain.c
--- programs/wcmd/wcmdmain.c	22 Aug 2003 05:01:59 -0000	1.34
+++ programs/wcmd/wcmdmain.c	26 Aug 2003 18:49:10 -0000
@@ -260,7 +260,7 @@
     DWORD count;
     HANDLE old_stdin = 0, old_stdout = 0, h;
     char *whichcmd;
-
+    SECURITY_ATTRIBUTES sa;
 
 /*
  *	Expand up environment variables.
@@ -287,12 +287,15 @@
 
     /* Dont issue newline WCMD_output (newline);           @JED*/
 
+    sa.nLength = sizeof(sa);
+    sa.lpSecurityDescriptor = NULL;
+    sa.bInheritHandle = TRUE;
 /*
  *	Redirect stdin and/or stdout if required.
  */
 
     if ((p = strchr(cmd,'<')) != NULL) {
-      h = CreateFile (WCMD_parameter (++p, 0, NULL), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
+      h = CreateFile (WCMD_parameter (++p, 0, NULL), GENERIC_READ, FILE_SHARE_READ, &sa, OPEN_EXISTING,
 		FILE_ATTRIBUTE_NORMAL, NULL);
       if (h == INVALID_HANDLE_VALUE) {
 	WCMD_print_error ();
@@ -303,7 +306,7 @@
       SetStdHandle (STD_INPUT_HANDLE, h);
     }
     if ((p = strchr(cmd,'>')) != NULL) {
-      h = CreateFile (WCMD_parameter (++p, 0, NULL), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
+      h = CreateFile (WCMD_parameter (++p, 0, NULL), GENERIC_WRITE, 0, &sa, CREATE_ALWAYS,
 		FILE_ATTRIBUTE_NORMAL, NULL);
       if (h == INVALID_HANDLE_VALUE) {
 	WCMD_print_error ();
@@ -531,8 +534,8 @@
   console = SHGetFileInfo (filetorun, 0, &psfi, sizeof(psfi), SHGFI_EXETYPE);
   ZeroMemory (&st, sizeof(STARTUPINFO));
   st.cb = sizeof(STARTUPINFO);
-  status = CreateProcess (NULL, command, NULL, NULL, FALSE,
-  		 0, NULL, NULL, &st, &pe);
+  status = CreateProcess (NULL, command, NULL, NULL, TRUE, 
+                          0, NULL, NULL, &st, &pe);
   if (!status) {
     WCMD_print_error ();
     return;
@@ -544,6 +547,8 @@
       GetExitCodeProcess (pe.hProcess, &errorlevel);
       if (errorlevel == STILL_ACTIVE) errorlevel = 0;
   }
+  CloseHandle(pe.hProcess);
+  CloseHandle(pe.hThread);
 }
 
 /******************************************************************************


More information about the wine-patches mailing list