Commit 61cb7045 authored by Oleg Prokhorov's avatar Oleg Prokhorov Committed by Alexandre Julliard

No handles were inherited in CreateProcess, all child console programs

were silent. Eric Pouech <pouech-eric@wanadoo.fr> Ensure redirected stream handle for child process are actually inheritable.
parent 78cd2879
...@@ -260,7 +260,7 @@ void WCMD_process_command (char *command) ...@@ -260,7 +260,7 @@ void WCMD_process_command (char *command)
DWORD count; DWORD count;
HANDLE old_stdin = 0, old_stdout = 0, h; HANDLE old_stdin = 0, old_stdout = 0, h;
char *whichcmd; char *whichcmd;
SECURITY_ATTRIBUTES sa;
/* /*
* Expand up environment variables. * Expand up environment variables.
...@@ -287,12 +287,15 @@ void WCMD_process_command (char *command) ...@@ -287,12 +287,15 @@ void WCMD_process_command (char *command)
/* Dont issue newline WCMD_output (newline); @JED*/ /* Dont issue newline WCMD_output (newline); @JED*/
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
/* /*
* Redirect stdin and/or stdout if required. * Redirect stdin and/or stdout if required.
*/ */
if ((p = strchr(cmd,'<')) != NULL) { 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); FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) { if (h == INVALID_HANDLE_VALUE) {
WCMD_print_error (); WCMD_print_error ();
...@@ -303,7 +306,7 @@ void WCMD_process_command (char *command) ...@@ -303,7 +306,7 @@ void WCMD_process_command (char *command)
SetStdHandle (STD_INPUT_HANDLE, h); SetStdHandle (STD_INPUT_HANDLE, h);
} }
if ((p = strchr(cmd,'>')) != NULL) { 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); FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) { if (h == INVALID_HANDLE_VALUE) {
WCMD_print_error (); WCMD_print_error ();
...@@ -531,8 +534,8 @@ char filetorun[MAX_PATH]; ...@@ -531,8 +534,8 @@ char filetorun[MAX_PATH];
console = SHGetFileInfo (filetorun, 0, &psfi, sizeof(psfi), SHGFI_EXETYPE); console = SHGetFileInfo (filetorun, 0, &psfi, sizeof(psfi), SHGFI_EXETYPE);
ZeroMemory (&st, sizeof(STARTUPINFO)); ZeroMemory (&st, sizeof(STARTUPINFO));
st.cb = sizeof(STARTUPINFO); st.cb = sizeof(STARTUPINFO);
status = CreateProcess (NULL, command, NULL, NULL, FALSE, status = CreateProcess (NULL, command, NULL, NULL, TRUE,
0, NULL, NULL, &st, &pe); 0, NULL, NULL, &st, &pe);
if (!status) { if (!status) {
WCMD_print_error (); WCMD_print_error ();
return; return;
...@@ -544,6 +547,8 @@ char filetorun[MAX_PATH]; ...@@ -544,6 +547,8 @@ char filetorun[MAX_PATH];
GetExitCodeProcess (pe.hProcess, &errorlevel); GetExitCodeProcess (pe.hProcess, &errorlevel);
if (errorlevel == STILL_ACTIVE) errorlevel = 0; if (errorlevel == STILL_ACTIVE) errorlevel = 0;
} }
CloseHandle(pe.hProcess);
CloseHandle(pe.hThread);
} }
/****************************************************************************** /******************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment