Commit 4121a29b authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

kernelbase: Don't use INVALID_HANDLE_VALUE as std handle in CreateProcess.

And don't infer detached console state from std handle values, but rely on a NULL console handle. Signed-off-by: 's avatarEric Pouech <epouech@codeweavers.com>
parent eba8b548
......@@ -3307,7 +3307,8 @@ struct std_handle_test
unsigned args;
/* output */
DWORD expected;
unsigned is_todo; /* bitmask: 1 on TEB values, 2 on StartupInfoA values, 4 on StartupInfoW values, 8 dangling in StartupInfoW */
unsigned is_todo; /* bitmask: 1 on TEB values, 2 on StartupInfoA values, 4 on StartupInfoW values,
8 dangling in StartupInfoW, 16 dangling in TEB */
DWORD is_broken; /* Win7 broken file types */
};
......@@ -3340,8 +3341,8 @@ static void test_StdHandleInheritance(void)
{ARG_STD | ARG_HANDLE_PROTECT | H_DISK, HATTR_TYPE | HATTR_PROTECT | FILE_TYPE_DISK},
/* all others handles type behave as H_DISK */
{ARG_STARTUPINFO | ARG_CP_INHERIT | H_DISK, HATTR_DANGLING, .is_todo = 8, .is_broken = HATTR_TYPE | FILE_TYPE_UNKNOWN},
{ARG_STD | ARG_CP_INHERIT | H_DISK, HATTR_DANGLING},
{ARG_STARTUPINFO | ARG_CP_INHERIT | H_DISK, HATTR_DANGLING, .is_todo = 24, .is_broken = HATTR_TYPE | FILE_TYPE_UNKNOWN},
{ARG_STD | ARG_CP_INHERIT | H_DISK, HATTR_DANGLING, .is_todo = 16},
/* all others handles type behave as H_DISK */
/*10*/ {ARG_STARTUPINFO | H_DEVIL, HATTR_NULL, .is_broken = HATTR_TYPE | FILE_TYPE_UNKNOWN},
......@@ -3368,8 +3369,8 @@ static void test_StdHandleInheritance(void)
{ARG_STD | ARG_HANDLE_INHERIT | H_DISK, HATTR_NULL},
/* all others handles type behave as H_DISK */
/*10*/ {ARG_STARTUPINFO | ARG_CP_INHERIT | H_DISK, HATTR_DANGLING, .is_todo = 8},
{ARG_STD | ARG_CP_INHERIT | H_DISK, HATTR_DANGLING},
/*10*/ {ARG_STARTUPINFO | ARG_CP_INHERIT | H_DISK, HATTR_DANGLING, .is_todo = 24},
{ARG_STD | ARG_CP_INHERIT | H_DISK, HATTR_DANGLING, .is_todo = 16},
/* all others handles type behave as H_DISK */
{ARG_STARTUPINFO | H_DISK, HATTR_NULL, .is_broken = HATTR_TYPE | FILE_TYPE_UNKNOWN},
......@@ -3467,7 +3468,7 @@ static void test_StdHandleInheritance(void)
okChildHexInt("StartupInfoW", "hStdOutput", (DWORD_PTR)hstd[1], std_tests[i].is_broken);
}
todo_wine
todo_wine_if(std_tests[i].is_todo & 16)
{
okChildHexInt("TEB", "hStdInput", (DWORD_PTR)hstd[0], std_tests[i].is_broken);
okChildHexInt("TEB", "hStdOutput", (DWORD_PTR)hstd[1], std_tests[i].is_broken);
......
......@@ -209,19 +209,17 @@ static RTL_USER_PROCESS_PARAMETERS *create_process_params( const WCHAR *filename
params->hStdOutput = startup->hStdOutput;
params->hStdError = startup->hStdError;
}
else if (flags & (DETACHED_PROCESS | CREATE_NEW_CONSOLE))
{
params->hStdInput = INVALID_HANDLE_VALUE;
params->hStdOutput = INVALID_HANDLE_VALUE;
params->hStdError = INVALID_HANDLE_VALUE;
}
else
else if (!(flags & (DETACHED_PROCESS | CREATE_NEW_CONSOLE)))
{
params->hStdInput = NtCurrentTeb()->Peb->ProcessParameters->hStdInput;
params->hStdOutput = NtCurrentTeb()->Peb->ProcessParameters->hStdOutput;
params->hStdError = NtCurrentTeb()->Peb->ProcessParameters->hStdError;
}
if (params->hStdInput == INVALID_HANDLE_VALUE) params->hStdInput = NULL;
if (params->hStdOutput == INVALID_HANDLE_VALUE) params->hStdOutput = NULL;
if (params->hStdError == INVALID_HANDLE_VALUE) params->hStdError = NULL;
params->dwX = startup->dwX;
params->dwY = startup->dwY;
params->dwXSize = startup->dwXSize;
......
......@@ -444,7 +444,7 @@ static NTSTATUS spawn_process( const RTL_USER_PROCESS_PARAMETERS *params, int so
if ((peb->ProcessParameters && params->ProcessGroupId != peb->ProcessParameters->ProcessGroupId) ||
params->ConsoleHandle == CONSOLE_HANDLE_ALLOC ||
params->ConsoleHandle == CONSOLE_HANDLE_ALLOC_NO_WINDOW ||
(params->hStdInput == INVALID_HANDLE_VALUE && params->hStdOutput == INVALID_HANDLE_VALUE))
params->ConsoleHandle == NULL)
{
setsid();
set_stdio_fd( -1, -1 ); /* close stdin and stdout */
......@@ -623,7 +623,7 @@ static NTSTATUS fork_and_exec( OBJECT_ATTRIBUTES *attr, int unixdir,
if ((peb->ProcessParameters && params->ProcessGroupId != peb->ProcessParameters->ProcessGroupId) ||
params->ConsoleHandle == CONSOLE_HANDLE_ALLOC ||
params->ConsoleHandle == CONSOLE_HANDLE_ALLOC_NO_WINDOW ||
(params->hStdInput == INVALID_HANDLE_VALUE && params->hStdOutput == INVALID_HANDLE_VALUE))
params->ConsoleHandle == NULL)
{
setsid();
set_stdio_fd( -1, -1 ); /* close stdin and stdout */
......
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