Fixes to hang on TTY child process exit

This commit is contained in:
manojampalam 2016-10-20 22:14:42 -07:00
parent 08cda06aa2
commit 46a6cc9c7c
2 changed files with 11 additions and 3 deletions

View File

@ -1116,9 +1116,13 @@ int start_with_pty(int ac, wchar_t **av) {
childProcessId = pi.dwProcessId;
FreeConsole();
Sleep(20);
while (!AttachConsole(pi.dwProcessId))
{
Sleep(1000);
DWORD exit_code;
if (GetExitCodeProcess(pi.hProcess, &exit_code) && exit_code != STILL_ACTIVE)
break;
Sleep(100);
}
/* monitor child exist */

View File

@ -567,7 +567,7 @@ int do_exec_windows(Session *s, const char *command, int pty) {
free(tmp);
if (s->display)
SetEnvironmentVariableW(L"DISPLAY", s->display);
SetEnvironmentVariableA("DISPLAY", s->display);
//_wchdir(pw_dir_w);
@ -674,8 +674,12 @@ int do_exec_windows(Session *s, const char *command, int pty) {
FreeConsole();
if (!debug_flag)
ImpersonateLoggedOnUser(hToken);
Sleep(20);
while (AttachConsole(pi.dwProcessId) == FALSE) {
Sleep(200);
DWORD exit_code;
if (GetExitCodeProcess(pi.hProcess, &exit_code) && exit_code != STILL_ACTIVE)
break;
Sleep(100);
}
if (!debug_flag)
RevertToSelf();