SYN SYN
[p5sagit/p5-mst-13.2.git] / t / io / pipe.t
index 1c72440..96935e3 100755 (executable)
@@ -1,10 +1,8 @@
 #!./perl
 
-# $RCSfile: pipe.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:31 $
-
 BEGIN {
     chdir 't' if -d 't';
-    unshift @INC, '../lib';
+    @INC = '../lib';
     require Config; import Config;
     unless ($Config{'d_fork'}) {
        print "1..0 # Skip: no fork\n";
@@ -13,7 +11,7 @@ BEGIN {
 }
 
 $| = 1;
-print "1..14\n";
+print "1..15\n";
 
 # External program 'tr' assumed.
 open(PIPE, "|-") || (exec 'tr', 'YX', 'ko');
@@ -61,6 +59,7 @@ if ($^O eq 'vmesa') {
        exec 'echo', 'not ok 6';
     }
 }
+wait;                          # Collect from $pid
 
 pipe(READER,WRITER) || die "Can't open pipe";
 close READER;
@@ -99,7 +98,7 @@ if ($Config{d_sfio} || $^O eq 'machten' || $^O eq 'beos' || $^O eq 'posix-bc') {
 else {
     local $SIG{PIPE} = 'IGNORE';
     open NIL, '|true'  or die "open failed: $!";
-    sleep 2;
+    sleep 5;
     print NIL 'foo'    or die "print failed: $!";
     if (close NIL) {
        print "not ok 9\n";
@@ -133,23 +132,27 @@ else {
     print "ok 10\n";
 }
 
-# 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 };
-alarm(1);
-my $close = close FH;
-if ($? == 13*256 && ! length $close && ! $!) {
-    print "ok 11\n";
-} else {
-    print "not ok 11\n# close $close\$?=$?   \$!=", $!+0, ":$!\n";
-};
-my $wait = wait;
-if ($? == 37*256 && $wait == $zombie && ! $!) {
-    print "ok 12\n";
+if ($^O eq 'mpeix') {
+    print "ok 11 # skipped\n";
+    print "ok 12 # skipped\n";
 } else {
-    print "not ok 12\n# pid=$wait first=$pid pipe=$pipe zombie=$zombie me=$$ \$?=$?   \$!=", $!+0, ":$!\n";
+    # check that status for the correct process is collected
+    my $zombie = fork or exit 37;
+    my $pipe = open *FH, "sleep 2;exit 13|" or die "Open: $!\n";
+    $SIG{ALRM} = sub { return };
+    alarm(1);
+    my $close = close FH;
+    if ($? == 13*256 && ! length $close && ! $!) {
+        print "ok 11\n";
+    } else {
+        print "not ok 11\n# close $close\$?=$?   \$!=", $!+0, ":$!\n";
+    };
+    my $wait = wait;
+    if ($? == 37*256 && $wait == $zombie && ! $!) {
+        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
@@ -158,3 +161,16 @@ if ($? == 37*256 && $wait == $zombie && ! $!) {
   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;