pipe.t revision 7c478bd95313f5f23a4c958a745db2134aa03244
#!./perl
BEGIN {
chdir 't' if -d 't';
print "1..0 # Skip: no fork\n";
exit 0;
}
}
$| = 1;
print "1..16\n";
# External program 'tr' assumed.
print PIPE "Xk 1\n";
print PIPE "oY 2\n";
# Doesn't work, yet.
for (3..6) {
print "ok $_ # skipped\n";
}
} else {
s/^not //;
print;
}
}
else {
# External program 'echo' assumed.
exec 'echo', 'not ok 4';
}
s/^not //;
print;
}
}
else {
# External program 'echo' assumed.
exec 'echo', 'not ok 6';
}
}
wait; # Collect from $pid
sub broken_pipe {
print "ok 7\n";
}
print WRITER "not ok 7\n";
sleep 1;
print "ok 8\n";
# VMS doesn't like spawning subprocesses that are still connected to
# STDOUT. Someone should modify tests #9 to #12 to work with VMS.
print "ok 9 # skipped\n";
print "ok 10 # skipped\n";
print "ok 11 # skipped\n";
print "ok 12 # skipped\n";
exit;
}
# Sfio doesn't report failure when closing a broken pipe
# that has pending output. Go figure. MachTen doesn't either,
# 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 # skipped\n";
}
else {
sleep 5;
print "not ok 9\n";
}
else {
print "ok 9\n";
}
}
# These don't work, yet.
print "ok 10 # skipped\n";
print "ok 11 # skipped\n";
print "ok 12 # skipped\n";
exit;
}
# check that errno gets forced to 0 if the piped program exited non-zero
$! = 1;
print "not ok 10\n# successful close\n";
}
elsif ($! != 0) {
print "not ok 10\n# errno $!\n";
}
elsif ($? == 0) {
print "not ok 10\n# status 0\n";
}
else {
print "ok 10\n";
}
print "ok 11 # skipped\n";
print "ok 12 # skipped\n";
} else {
# check that status for the correct process is collected
print "ok 11\n";
} else {
};
my $wait = wait;
print "ok 12\n";
} 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;
}
# check that status is unaffected by implicit close
{
$? = 42;
# NIL implicitly closed here
}
if ($? != 42) {
print "# status $?, expected 42\nnot ";
}
print "ok 15\n";
$? = 0;
# check that child is reaped if the piped program can't be executed
{
my $child = 0;
eval {
alarm 2;
$child = wait;
alarm 0;
};
print "ok 16\n";
}