TerminalStudio / flutter_pty

Pty for Flutter. Provides the ability to create processes with pseudo terminal file descriptors.
https://pub.dev/packages/flutter_pty
MIT License
24 stars 21 forks source link

Windows OS conhost problem #5

Open movade005 opened 1 year ago

movade005 commented 1 year ago

I think you should use "ClosePseudoConsole" in "flutter_pty_win.c" , in function start_wait_exit_thread , here is the code: static DWORD WINAPI wait_exit_thread(LPVOID arg) { WaitExitOptions options = (WaitExitOptions )arg;

DWORD exit_code = 0;

WaitForSingleObject(options->pid, INFINITE);

GetExitCodeProcess(options->pid, &exit_code);

CloseHandle(options->pid);
CloseHandle(options->hMutex);
ClosePseudoConsole(options->hpty);      // To close the PseudoConsole

Dart_PostInteger_DL(options->port, exit_code);

return 0;

}

static void start_wait_exit_thread(HANDLE pid, Dart_Port port, HANDLE mutex, HPCON hpty) { WaitExitOptions *options = malloc(sizeof(WaitExitOptions));

options->pid = pid;
options->port = port;
options->hMutex = mutex;
options->hpty = hpty;  //  add htpy

DWORD thread_id;

HANDLE thread = CreateThread(NULL, 0, wait_exit_thread, options, 0, &thread_id);

if (thread == NULL)
{
    free(options);
}

}

If not close the Pseudo , when close the port , there is a conhost process can not be kill.