diff options
author | Brent Cook <busterb@gmail.com> | 2015-12-05 22:14:42 -0600 |
---|---|---|
committer | Brent Cook <bcook@openbsd.org> | 2015-12-06 16:49:01 -0600 |
commit | afcc027da77f2285eda4c018348a3794c667581d (patch) | |
tree | 8eee108720ac9624f4b06a1dc718a9acaeba8e36 | |
parent | 75ef5bb160fb261da1950abfd3d22f54011458e1 (diff) | |
download | portable-afcc027da77f2285eda4c018348a3794c667581d.tar.gz portable-afcc027da77f2285eda4c018348a3794c667581d.tar.bz2 portable-afcc027da77f2285eda4c018348a3794c667581d.zip |
only set the console mode if stdin is a console (not a pipe)
This allows piping commands and running from a cygwin console.
-rw-r--r-- | crypto/compat/ui_openssl_win.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/crypto/compat/ui_openssl_win.c b/crypto/compat/ui_openssl_win.c index 13e93bc..aaab60b 100644 --- a/crypto/compat/ui_openssl_win.c +++ b/crypto/compat/ui_openssl_win.c | |||
@@ -301,27 +301,39 @@ open_console(UI *ui) | |||
301 | tty_in = stdin; | 301 | tty_in = stdin; |
302 | tty_out = stderr; | 302 | tty_out = stderr; |
303 | 303 | ||
304 | HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); | 304 | HANDLE handle = (HANDLE)_get_osfhandle(STDIN_FILENO); |
305 | if (handle != INVALID_HANDLE_VALUE) | 305 | if (handle != INVALID_HANDLE_VALUE) { |
306 | return GetConsoleMode(handle, &console_mode); | 306 | if (GetFileType(handle) == FILE_TYPE_CHAR) |
307 | return GetConsoleMode(handle, &console_mode); | ||
308 | else | ||
309 | return 1; | ||
310 | } | ||
307 | return 0; | 311 | return 0; |
308 | } | 312 | } |
309 | 313 | ||
310 | static int | 314 | static int |
311 | noecho_console(UI *ui) | 315 | noecho_console(UI *ui) |
312 | { | 316 | { |
313 | HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); | 317 | HANDLE handle = (HANDLE)_get_osfhandle(STDIN_FILENO); |
314 | if (handle != INVALID_HANDLE_VALUE) | 318 | if (handle != INVALID_HANDLE_VALUE) { |
315 | return SetConsoleMode(handle, console_mode & ~ENABLE_ECHO_INPUT); | 319 | if (GetFileType(handle) == FILE_TYPE_CHAR) |
320 | return SetConsoleMode(handle, console_mode & ~ENABLE_ECHO_INPUT); | ||
321 | else | ||
322 | return 1; | ||
323 | } | ||
316 | return 0; | 324 | return 0; |
317 | } | 325 | } |
318 | 326 | ||
319 | static int | 327 | static int |
320 | echo_console(UI *ui) | 328 | echo_console(UI *ui) |
321 | { | 329 | { |
322 | HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); | 330 | HANDLE handle = (HANDLE)_get_osfhandle(STDIN_FILENO); |
323 | if (handle != INVALID_HANDLE_VALUE) | 331 | if (handle != INVALID_HANDLE_VALUE) { |
324 | return SetConsoleMode(handle, console_mode); | 332 | if (GetFileType(handle) == FILE_TYPE_CHAR) |
333 | return SetConsoleMode(handle, console_mode); | ||
334 | else | ||
335 | return 1; | ||
336 | } | ||
325 | return 0; | 337 | return 0; |
326 | } | 338 | } |
327 | 339 | ||