aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/io.c b/io.c
index 91c94d9b..bcaff3c3 100644
--- a/io.c
+++ b/io.c
@@ -1375,6 +1375,9 @@ close_redir(struct redirect *rp, bool exitwarn, two_way_close_type how)
if (rp == NULL)
return 0;
+ if ((rp->flag & RED_WRITE) && rp->output.fp)
+ /* flush before closing to leverage special error handling */
+ efflush(rp->output.fp, "flush", rp);
if (rp->output.fp == stdout || rp->output.fp == stderr)
goto checkwarn; /* bypass closing, remove from list */