diff options
author | Abhijit Menon-Sen <ams@wiw.org> | 2002-02-16 02:43:59 +0000 |
---|---|---|
committer | Abhijit Menon-Sen <ams@wiw.org> | 2002-02-16 02:43:59 +0000 |
commit | e212fc47535368d2c67d798e231108ada401dee1 (patch) | |
tree | 172ada9591f44b9b1ef95880068e247c12adf4bd /doio.c | |
parent | 050dfae09d60a26290397d38efa5f4e336bef7e0 (diff) | |
download | perl-e212fc47535368d2c67d798e231108ada401dee1.tar.gz |
Absorb #14701 by Sarathy from maint-5.6.
p4raw-id: //depot/perl@14714
Diffstat (limited to 'doio.c')
-rw-r--r-- | doio.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -600,9 +600,16 @@ Perl_do_openn(pTHX_ GV *gv, register char *name, I32 len, int as_raw, UNLOCK_FDPID_MUTEX; (void)SvUPGRADE(sv, SVt_IV); SvIVX(sv) = pid; - if (!was_fdopen) { - PerlIO_close(fp); + if (was_fdopen) { + /* need to close fp without closing underlying fd */ + int ofd = PerlIO_fileno(fp); + int dupfd = PerlLIO_dup(ofd); + PerlIO_close(fp); + PerlLIO_dup2(dupfd,ofd); + PerlLIO_close(dupfd); } + else + PerlIO_close(fp); } fp = saveifp; PerlIO_clearerr(fp); |