summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2015-11-04 16:52:37 +1100
committerRicardo Signes <rjbs@cpan.org>2016-03-17 19:52:56 -0400
commit8abddda39a55d116a506c465ef0ccd0f8546b896 (patch)
tree5509cbb4988496c479a8b0b5acf693936eec7ad8 /perl.c
parent756bd853cd4bf0ba281f8bf508596fbb779c4a5c (diff)
downloadperl-8abddda39a55d116a506c465ef0ccd0f8546b896.tar.gz
report an error and fail if we can't flush stdout
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/perl.c b/perl.c
index 5c71fd0c39..94c810e622 100644
--- a/perl.c
+++ b/perl.c
@@ -585,6 +585,19 @@ perl_destruct(pTHXx)
assert(PL_scopestack_ix == 0);
/* Need to flush since END blocks can produce output */
+ /* flush stdout separately, since we can identify it */
+#ifdef USE_PERLIO
+ {
+ PerlIO *stdo = PerlIO_stdout();
+ if (*stdo && PerlIO_flush(stdo)) {
+ PerlIO_restore_errno(stdo);
+ PerlIO_printf(PerlIO_stderr(), "Unable to flush stdout: %s",
+ Strerror(errno));
+ if (!STATUS_UNIX)
+ STATUS_ALL_FAILURE;
+ }
+ }
+#endif
my_fflush_all();
#ifdef PERL_TRACE_OPS