}
return FALSE;
}
- retval = io_close(io);
+ retval = io_close(io, not_implicit);
if (not_implicit) {
IoLINES(io) = 0;
IoPAGE(io) = 0;
}
bool
-Perl_io_close(pTHX_ IO *io)
+Perl_io_close(pTHX_ IO *io, bool not_implicit)
{
bool retval = FALSE;
int status;
if (IoIFP(io)) {
if (IoTYPE(io) == '|') {
status = PerlProc_pclose(IoIFP(io));
- STATUS_NATIVE_SET(status);
- retval = (STATUS_POSIX == 0);
+ if (not_implicit) {
+ STATUS_NATIVE_SET(status);
+ retval = (STATUS_POSIX == 0);
+ }
+ else {
+ retval = (status != -1);
+ }
}
else if (IoTYPE(io) == '-')
retval = TRUE;
}
IoOFP(io) = IoIFP(io) = Nullfp;
}
- else {
+ else if (not_implicit) {
SETERRNO(EBADF,SS$_IVCHAN);
}
#define init_stacks() Perl_init_stacks(aTHX)
#define intro_my() Perl_intro_my(aTHX)
#define instr(a,b) Perl_instr(aTHX_ a,b)
-#define io_close(a) Perl_io_close(aTHX_ a)
+#define io_close(a,b) Perl_io_close(aTHX_ a,b)
#define invert(a) Perl_invert(aTHX_ a)
#define is_uni_alnum(a) Perl_is_uni_alnum(aTHX_ a)
#define is_uni_alnumc(a) Perl_is_uni_alnumc(aTHX_ a)
p |void |init_stacks
p |U32 |intro_my
p |char* |instr |const char* big|const char* little
-p |bool |io_close |IO* io
+p |bool |io_close |IO* io|bool not_implicit
p |OP* |invert |OP* cmd
p |bool |is_uni_alnum |U32 c
p |bool |is_uni_alnumc |U32 c
#undef Perl_io_close
bool
-Perl_io_close(pTHXo_ IO* io)
+Perl_io_close(pTHXo_ IO* io, bool not_implicit)
{
- return ((CPerlObj*)pPerl)->Perl_io_close(io);
+ return ((CPerlObj*)pPerl)->Perl_io_close(io, not_implicit);
}
#undef Perl_invert
VIRTUAL void Perl_init_stacks(pTHX);
VIRTUAL U32 Perl_intro_my(pTHX);
VIRTUAL char* Perl_instr(pTHX_ const char* big, const char* little);
-VIRTUAL bool Perl_io_close(pTHX_ IO* io);
+VIRTUAL bool Perl_io_close(pTHX_ IO* io, bool not_implicit);
VIRTUAL OP* Perl_invert(pTHX_ OP* cmd);
VIRTUAL bool Perl_is_uni_alnum(pTHX_ U32 c);
VIRTUAL bool Perl_is_uni_alnumc(pTHX_ U32 c);
IoIFP(sv) != PerlIO_stdout() &&
IoIFP(sv) != PerlIO_stderr())
{
- io_close((IO*)sv);
+ io_close((IO*)sv, FALSE);
}
if (IoDIRP(sv)) {
PerlDir_close(IoDIRP(sv));
#!./perl
-# $RCSfile: pipe.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:31 $
-
BEGIN {
chdir 't' if -d 't';
unshift @INC, '../lib';
}
$| = 1;
-print "1..14\n";
+print "1..15\n";
# External program 'tr' assumed.
open(PIPE, "|-") || (exec 'tr', 'YX', 'ko');
print (((open P, "| " ) ? "not " : ""), "ok 13\n");
print (((open P, " |" ) ? "not " : ""), "ok 14\n");
}
+
+# check that status is unaffected by implicit close
+{
+ local(*NIL);
+ open NIL, '|exit 23;' or die "fork failed: $!";
+ $? = 42;
+ # NIL implicitly closed here
+}
+if ($? != 42) {
+ print "# status $?, expected 42\nnot ";
+}
+print "ok 15\n";
+$? = 0;