Mercurial > hg > release > icedtea8-forest-3.0 > jdk
changeset 10747:019f2d939ddc
8067748: (process) Child is terminated when parent's console is closed [win]
Reviewed-by: alanb
author | igerasim |
---|---|
date | Fri, 23 Jan 2015 13:57:02 +0300 |
parents | 628cb66e781b |
children | 5909ec3c62e3 |
files | src/windows/native/java/lang/ProcessImpl_md.c |
diffstat | 1 files changed, 13 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/windows/native/java/lang/ProcessImpl_md.c Tue Feb 17 10:43:46 2015 -0800 +++ b/src/windows/native/java/lang/ProcessImpl_md.c Fri Jan 23 13:57:02 2015 +0300 @@ -272,14 +272,10 @@ FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}; - { - /* Extraction of current process standard IOE handles */ - DWORD idsIOE[3] = {STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, STD_ERROR_HANDLE}; - int i; - for (i = 0; i < 3; ++i) - /* Should not be closed by CloseHandle! */ - stdIOE[i] = GetStdHandle(idsIOE[i]); - } + /* These three should not be closed by CloseHandle! */ + stdIOE[0] = GetStdHandle(STD_INPUT_HANDLE); + stdIOE[1] = GetStdHandle(STD_OUTPUT_HANDLE); + stdIOE[2] = GetStdHandle(STD_ERROR_HANDLE); prepareIOEHandleState(stdIOE, inherit); { @@ -308,11 +304,16 @@ if (success) { PROCESS_INFORMATION pi; - DWORD processFlag = CREATE_UNICODE_ENVIRONMENT; + DWORD processFlag = CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT; - /* Suppress popping-up of a console window for non-console applications */ - if (GetConsoleWindow() == NULL) - processFlag |= CREATE_NO_WINDOW; + /* If the standard I/O is inherited, CREATE_NO_WINDOW must not be used. */ + if (GetConsoleWindow() != NULL && + (si.hStdInput == stdIOE[0] || + si.hStdOutput == stdIOE[1] || + si.hStdError == (redirectErrorStream ? stdIOE[1] : stdIOE[2]))) + { + processFlag &= ~CREATE_NO_WINDOW; + } si.dwFlags = STARTF_USESTDHANDLES; if (!CreateProcessW(