/* doio.c
*
- * Copyright (c) 1991-2003, Larry Wall
+ * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+ * 2000, 2001, 2002, 2003, by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
/* need to close fp without closing underlying fd */
int ofd = PerlIO_fileno(fp);
int dupfd = PerlLIO_dup(ofd);
+#if defined(HAS_FCNTL) && defined(F_SETFD)
+ /* Assume if we have F_SETFD we have F_GETFD */
+ int coe = fcntl(ofd,F_GETFD);
+#endif
PerlIO_close(fp);
PerlLIO_dup2(dupfd,ofd);
+#if defined(HAS_FCNTL) && defined(F_SETFD)
+ /* The dup trick has lost close-on-exec on ofd */
+ fcntl(ofd,F_SETFD, coe);
+#endif
PerlLIO_close(dupfd);
}
else
#endif
}
PL_filemode = 0;
+ if (!GvAV(gv))
+ return Nullfp;
while (av_len(GvAV(gv)) >= 0) {
STRLEN oldlen;
sv = av_shift(GvAV(gv));
report_evil_fh(gv, io, OP_phoney_OUTPUT_ONLY);
while (IoIFP(io)) {
+ int saverrno;
if (PerlIO_has_cntptr(IoIFP(io))) { /* (the code works without this) */
if (PerlIO_get_cnt(IoIFP(io)) > 0) /* cheat a little, since */
return FALSE; /* this is the most usual case */
}
+ saverrno = errno; /* getc and ungetc can stomp on errno */
ch = PerlIO_getc(IoIFP(io));
if (ch != EOF) {
(void)PerlIO_ungetc(IoIFP(io),ch);
+ errno = saverrno;
return FALSE;
}
+ errno = saverrno;
if (PerlIO_has_cntptr(IoIFP(io)) && PerlIO_canset_cnt(IoIFP(io))) {
if (PerlIO_get_cnt(IoIFP(io)) < -1)
return PL_laststatval;
}
+#ifndef OS2
bool
Perl_do_aexec(pTHX_ SV *really, register SV **mark, register SV **sp)
{
return do_aexec5(really, mark, sp, 0, 0);
}
+#endif
bool
Perl_do_aexec5(pTHX_ SV *really, register SV **mark, register SV **sp,