From: Rafael Garcia-Suarez Date: Thu, 10 Mar 2005 17:42:54 +0000 (+0000) Subject: Make the return value of close() depend not only on the success of the X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e199e3bef188fd5eadcca420af186241e2773db1;p=p5sagit%2Fp5-mst-13.2.git 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 , via Debian. p4raw-id: //depot/perl@24022 --- diff --git a/doio.c b/doio.c index 6fe0c85..df7f656 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; }