summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-03-10 17:42:54 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-03-10 17:42:54 +0000
commite199e3bef188fd5eadcca420af186241e2773db1 (patch)
treebe284908c5f675859483d5d54c190c70e20a565e /doio.c
parent6ed007ae6b14c10b7b8e33947dc7bbed976b6e7c (diff)
downloadperl-e199e3bef188fd5eadcca420af186241e2773db1.tar.gz
Make the return value of close() depend not only on the success of the
close itself, but also on whether the output stream had a previous error. From Jim Meyering <jim@meyering.net>, via Debian. p4raw-id: //depot/perl@24022
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/doio.c b/doio.c
index 6fe0c85826..df7f656c87 100644
--- a/doio.c
+++ b/doio.c
@@ -1059,11 +1059,14 @@ Perl_io_close(pTHX_ IO *io, bool not_implicit)
retval = TRUE;
else {
if (IoOFP(io) && IoOFP(io) != IoIFP(io)) { /* a socket */
- retval = (PerlIO_close(IoOFP(io)) != EOF);
+ bool prev_err = PerlIO_error(IoOFP(io));
+ retval = (PerlIO_close(IoOFP(io)) != EOF && !prev_err);
PerlIO_close(IoIFP(io)); /* clear stdio, fd already closed */
}
- else
- retval = (PerlIO_close(IoIFP(io)) != EOF);
+ else {
+ bool prev_err = PerlIO_error(IoIFP(io));
+ retval = (PerlIO_close(IoIFP(io)) != EOF && !prev_err);
+ }
}
IoOFP(io) = IoIFP(io) = Nullfp;
}