1N/A#!./perl -w
1N/A
1N/ABEGIN {
1N/A chdir 't' if -d 't';
1N/A @INC = '../lib';
1N/A require Config; import Config;
1N/A if (!$Config{'d_fork'}
1N/A # open2/3 supported on win32 (but not Borland due to CRT bugs)
1N/A && (($^O ne 'MSWin32' && $^O ne 'NetWare') || $Config{'cc'} =~ /^bcc/i))
1N/A {
1N/A print "1..0\n";
1N/A exit 0;
1N/A }
1N/A # make warnings fatal
1N/A $SIG{__WARN__} = sub { die @_ };
1N/A}
1N/A
1N/Ause strict;
1N/Ause IO::Handle;
1N/Ause IPC::Open2;
1N/A#require 'open2.pl'; use subs 'open2';
1N/A
1N/Amy $perl = './perl';
1N/A
1N/Asub ok {
1N/A my ($n, $result, $info) = @_;
1N/A if ($result) {
1N/A print "ok $n\n";
1N/A }
1N/A else {
1N/A print "not ok $n\n";
1N/A print "# $info\n" if $info;
1N/A }
1N/A}
1N/A
1N/Asub cmd_line {
1N/A if ($^O eq 'MSWin32' || $^O eq 'NetWare') {
1N/A return qq/"$_[0]"/;
1N/A }
1N/A else {
1N/A return $_[0];
1N/A }
1N/A}
1N/A
1N/Amy ($pid, $reaped_pid);
1N/ASTDOUT->autoflush;
1N/ASTDERR->autoflush;
1N/A
1N/Aprint "1..7\n";
1N/A
1N/Aok 1, $pid = open2 'READ', 'WRITE', $perl, '-e',
1N/A cmd_line('print scalar <STDIN>');
1N/Aok 2, print WRITE "hi kid\n";
1N/Aok 3, <READ> =~ /^hi kid\r?\n$/;
1N/Aok 4, close(WRITE), $!;
1N/Aok 5, close(READ), $!;
1N/A$reaped_pid = waitpid $pid, 0;
1N/Aok 6, $reaped_pid == $pid, $reaped_pid;
1N/Aok 7, $? == 0, $?;