diff options
author | Chuck Craft <bubbasnmp@gmail.com> | 2020-10-30 15:10:46 +0000 |
---|---|---|
committer | Pascal Quantin <pascal@wireshark.org> | 2020-11-02 13:52:36 +0000 |
commit | 5497552ab158b5672e03129e204e0ceb477d3c6f (patch) | |
tree | 3380e987de2faab4a20ff0399ba00877168c6a41 /ui | |
parent | 15f52841ca14ca8f45c9325ec8898b74ed34db60 (diff) |
win32: fix MR180 - broke "-i -" input pipe
(cherry picked from commit 44241f694e984ea3935348e571155bbc8ff73cc7)
Diffstat (limited to 'ui')
-rw-r--r-- | ui/win32/console_win32.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ui/win32/console_win32.c b/ui/win32/console_win32.c index cd568ae3be..6be5b8d1e5 100644 --- a/ui/win32/console_win32.c +++ b/ui/win32/console_win32.c @@ -210,6 +210,8 @@ restore_pipes(void) gboolean must_redirect_stdout; gboolean must_redirect_stderr; + HANDLE fd; + if (stdin_capture) { /* We've been handed "-i -". Don't mess with stdio. */ return; @@ -228,6 +230,9 @@ restore_pipes(void) if (!must_redirect_stdin && !must_redirect_stdout && !must_redirect_stderr) return; + if (!must_redirect_stdin) + fd = GetStdHandle(STD_INPUT_HANDLE); + /* OK, at least one of them needs to be redirected to a console; try to attach to the parent process's console and, if that fails, cleanup and return. */ @@ -240,8 +245,11 @@ restore_pipes(void) return; /* No parent - cleanup and exit */ } - if (must_redirect_stdin) + if (must_redirect_stdin) { ws_freopen("CONIN$", "r", stdin); + } else { + SetStdHandle(STD_INPUT_HANDLE, fd); + } if (must_redirect_stdout) { ws_freopen("CONOUT$", "w", stdout); fprintf(stdout, "\n"); |