diff options
author | Abhijit Menon-Sen <ams@wiw.org> | 2002-02-18 20:21:17 +0000 |
---|---|---|
committer | Abhijit Menon-Sen <ams@wiw.org> | 2002-02-18 20:21:17 +0000 |
commit | d0e2cf6390c2ab73adcabc3831e68e4987791f31 (patch) | |
tree | 7b197b29dbaecaa466e0755bbd344a6234f9907b /doio.c | |
parent | 25caadfde7ae3eed2404429001226c26e41fa4a0 (diff) | |
download | perl-d0e2cf6390c2ab73adcabc3831e68e4987791f31.tar.gz |
Forward port #14704 from maint-5.6.
p4raw-id: //depot/perl@14756
Diffstat (limited to 'doio.c')
-rw-r--r-- | doio.c | 43 |
1 files changed, 27 insertions, 16 deletions
@@ -572,8 +572,6 @@ Perl_do_openn(pTHX_ GV *gv, register char *name, I32 len, int as_raw, } } if (savefd != fd) { - Pid_t pid; - SV *sv; /* Still a small can-of-worms here if (say) PerlIO::Scalar is assigned to (say) STDOUT - for now let dup2() fail and provide the error @@ -584,22 +582,35 @@ Perl_do_openn(pTHX_ GV *gv, register char *name, I32 len, int as_raw, } #ifdef VMS if (savefd != PerlIO_fileno(PerlIO_stdin())) { - char newname[FILENAME_MAX+1]; - if (PerlIO_getname(fp, newname)) { - if (fd == PerlIO_fileno(PerlIO_stdout())) Perl_vmssetuserlnm(aTHX_ "SYS$OUTPUT", newname); - if (fd == PerlIO_fileno(PerlIO_stderr())) Perl_vmssetuserlnm(aTHX_ "SYS$ERROR", newname); - } + char newname[FILENAME_MAX+1]; + if (PerlIO_getname(fp, newname)) { + if (fd == PerlIO_fileno(PerlIO_stdout())) + Perl_vmssetuserlnm(aTHX_ "SYS$OUTPUT", newname); + if (fd == PerlIO_fileno(PerlIO_stderr())) + Perl_vmssetuserlnm(aTHX_ "SYS$ERROR", newname); + } } #endif - LOCK_FDPID_MUTEX; - sv = *av_fetch(PL_fdpid,fd,TRUE); - (void)SvUPGRADE(sv, SVt_IV); - pid = SvIVX(sv); - SvIVX(sv) = 0; - sv = *av_fetch(PL_fdpid,savefd,TRUE); - UNLOCK_FDPID_MUTEX; - (void)SvUPGRADE(sv, SVt_IV); - SvIVX(sv) = pid; + +#if !defined(WIN32) + /* PL_fdpid isn't used on Windows, so avoid this useless work. + * XXX Probably the same for a lot of other places. */ + { + Pid_t pid; + SV *sv; + + LOCK_FDPID_MUTEX; + sv = *av_fetch(PL_fdpid,fd,TRUE); + (void)SvUPGRADE(sv, SVt_IV); + pid = SvIVX(sv); + SvIVX(sv) = 0; + sv = *av_fetch(PL_fdpid,savefd,TRUE); + (void)SvUPGRADE(sv, SVt_IV); + SvIVX(sv) = pid; + UNLOCK_FDPID_MUTEX; + } +#endif + if (was_fdopen) { /* need to close fp without closing underlying fd */ int ofd = PerlIO_fileno(fp); |