#!./perl
-# $RCSfile: pipe.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:31 $
-
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib';
+ unshift @INC, '../lib';
require Config; import Config;
unless ($Config{'d_fork'}) {
- print "1..0\n";
+ print "1..0 # Skip: no fork\n";
exit 0;
}
}
$| = 1;
-print "1..12\n";
+print "1..15\n";
# External program 'tr' assumed.
open(PIPE, "|-") || (exec 'tr', 'YX', 'ko');
if ($^O eq 'vmesa') {
# Doesn't work, yet.
- print "ok 3\n";
- print "ok 4\n";
- print "ok 5\n";
- print "ok 6\n";
+ for (3..6) {
+ print "ok $_ # skipped\n";
+ }
} else {
if (open(PIPE, "-|")) {
while(<PIPE>) {
exec 'echo', 'not ok 6';
}
}
+wait; # Collect from $pid
pipe(READER,WRITER) || die "Can't open pipe";
close READER;
# STDOUT. Someone should modify tests #9 to #12 to work with VMS.
if ($^O eq 'VMS') {
- print "ok 9\n";
- print "ok 10\n";
- print "ok 11\n";
- print "ok 12\n";
+ print "ok 9 # skipped\n";
+ print "ok 10 # skipped\n";
+ print "ok 11 # skipped\n";
+ print "ok 12 # skipped\n";
exit;
}
# but won't write to broken pipes, so nothing's pending at close.
# BeOS will not write to broken pipes, either.
# Nor does POSIX-BC.
- print "ok 9\n";
+ print "ok 9 # skipped\n";
}
else {
local $SIG{PIPE} = 'IGNORE';
if ($^O eq 'vmesa') {
# These don't work, yet.
- print "ok 10\n";
- print "ok 11\n";
- print "ok 12\n";
+ print "ok 10 # skipped\n";
+ print "ok 11 # skipped\n";
+ print "ok 12 # skipped\n";
exit;
}
}
# check that status for the correct process is collected
-wait; # Collect from $pid
my $zombie = fork or exit 37;
my $pipe = open *FH, "sleep 2;exit 13|" or die "Open: $!\n";
$SIG{ALRM} = sub { return };
} else {
print "not ok 12\n# pid=$wait first=$pid pipe=$pipe zombie=$zombie me=$$ \$?=$? \$!=", $!+0, ":$!\n";
}
+
+# Test new semantics for missing command in piped open
+# 19990114 M-J. Dominus mjd@plover.com
+{ local *P;
+ 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;