diff options
-rw-r--r-- | shell/ash.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c index fd2a66270..a5b7dbc74 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -6542,6 +6542,12 @@ save_fd_on_redirect(int fd, int avoid_fd, struct redirtab *sq) | |||
6542 | if (fd == preverrout_fd) | 6542 | if (fd == preverrout_fd) |
6543 | preverrout_fd = new_fd; | 6543 | preverrout_fd = new_fd; |
6544 | 6544 | ||
6545 | #if ENABLE_PLATFORM_MINGW32 && !defined(_UCRT) | ||
6546 | // Workaround for problems with stderr in MSVCRT | ||
6547 | if (fd == fileno(stderr)) | ||
6548 | setvbuf(stderr, NULL, _IONBF, 0); | ||
6549 | #endif | ||
6550 | |||
6545 | return 0; /* "we did not close fd" */ | 6551 | return 0; /* "we did not close fd" */ |
6546 | } | 6552 | } |
6547 | 6553 | ||
@@ -6629,6 +6635,16 @@ redirect(union node *redir, int flags) | |||
6629 | if (!closed) { | 6635 | if (!closed) { |
6630 | /* ^^^ optimization: saving may already | 6636 | /* ^^^ optimization: saving may already |
6631 | * have closed it. If not... */ | 6637 | * have closed it. If not... */ |
6638 | #if ENABLE_PLATFORM_MINGW32 && !defined(_UCRT) && !defined(_WIN64) | ||
6639 | // Workaround for problems with streams in 32-bit MSVCRT | ||
6640 | if (fd == fileno(stdin)) | ||
6641 | fclose(stdin); | ||
6642 | else if (fd == fileno(stdout)) | ||
6643 | fclose(stdout); | ||
6644 | else if (fd == fileno(stderr)) | ||
6645 | fclose(stderr); | ||
6646 | else | ||
6647 | #endif | ||
6632 | close(fd); | 6648 | close(fd); |
6633 | } | 6649 | } |
6634 | } else { | 6650 | } else { |