By default, console handles are inheritable.

This commit is contained in:
Eric Pouech 2003-09-19 00:05:18 +00:00 committed by Alexandre Julliard
parent 52f692fb9b
commit 4df100cda6
1 changed files with 8 additions and 2 deletions

View File

@ -950,6 +950,7 @@ BOOL WINAPI AllocConsole(void)
STARTUPINFOA siCurrent; STARTUPINFOA siCurrent;
STARTUPINFOA siConsole; STARTUPINFOA siConsole;
char buffer[1024]; char buffer[1024];
SECURITY_ATTRIBUTES sa;
TRACE("()\n"); TRACE("()\n");
@ -988,12 +989,17 @@ BOOL WINAPI AllocConsole(void)
if (!start_console_renderer(&siConsole)) if (!start_console_renderer(&siConsole))
goto the_end; goto the_end;
/* all std I/O handles are inheritable by default */
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
handle_in = CreateFileA( "CONIN$", GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE, handle_in = CreateFileA( "CONIN$", GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE,
0, NULL, OPEN_EXISTING, 0, 0 ); 0, &sa, OPEN_EXISTING, 0, 0 );
if (handle_in == INVALID_HANDLE_VALUE) goto the_end; if (handle_in == INVALID_HANDLE_VALUE) goto the_end;
handle_out = CreateFileA( "CONOUT$", GENERIC_READ|GENERIC_WRITE, handle_out = CreateFileA( "CONOUT$", GENERIC_READ|GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, 0 ); 0, &sa, OPEN_EXISTING, 0, 0 );
if (handle_out == INVALID_HANDLE_VALUE) goto the_end; if (handle_out == INVALID_HANDLE_VALUE) goto the_end;
if (!DuplicateHandle(GetCurrentProcess(), handle_out, GetCurrentProcess(), &handle_err, if (!DuplicateHandle(GetCurrentProcess(), handle_out, GetCurrentProcess(), &handle_err,