diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2005-03-10 17:42:54 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2005-03-10 17:42:54 +0000 |
commit | e199e3bef188fd5eadcca420af186241e2773db1 (patch) | |
tree | be284908c5f675859483d5d54c190c70e20a565e /doio.c | |
parent | 6ed007ae6b14c10b7b8e33947dc7bbed976b6e7c (diff) | |
download | perl-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.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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; } |