Skip to content

Commit

Permalink
fix Windows OS conhost problem
Browse files Browse the repository at this point in the history
  • Loading branch information
anhhna committed Nov 3, 2023
1 parent 3621892 commit 4518f49
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/flutter_pty_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ typedef struct WaitExitOptions
Dart_Port port;

HANDLE hMutex;

HPCON hpty;
} WaitExitOptions;

static DWORD WINAPI wait_exit_thread(LPVOID arg)
Expand All @@ -240,19 +242,21 @@ static DWORD WINAPI wait_exit_thread(LPVOID arg)

CloseHandle(options->pid);
CloseHandle(options->hMutex);
ClosePseudoConsole(options->hpty);

Dart_PostInteger_DL(options->port, exit_code);

return 0;
}

static void start_wait_exit_thread(HANDLE pid, Dart_Port port, HANDLE mutex)
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;

DWORD thread_id;

Expand Down Expand Up @@ -410,7 +414,7 @@ FFI_PLUGIN_EXPORT PtyHandle *pty_create(PtyOptions *options)

start_read_thread(outputReadSide, options->stdout_port, mutex, options->ackRead);

start_wait_exit_thread(processInfo.hProcess, options->exit_port, mutex);
start_wait_exit_thread(processInfo.hProcess, options->exit_port, mutex, hPty);

PtyHandle *pty = malloc(sizeof(PtyHandle));

Expand Down

0 comments on commit 4518f49

Please sign in to comment.