BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
+ require Config; import Config;
+ unless ($Config{'d_fork'}) {
+ print "1..0\n";
+ exit 0;
+ }
# make warnings fatal
$SIG{__WARN__} = sub { die @_ };
}
use IPC::Open3;
#require 'open3.pl'; use subs 'open3';
+my $perl = './perl';
+
sub ok {
my ($n, $result, $info) = @_;
if ($result) {
print "1..21\n";
# basic
-ok 1, $pid = open3 'WRITE', 'READ', 'ERROR', $^X, '-e', <<'EOF';
+ok 1, $pid = open3 'WRITE', 'READ', 'ERROR', $perl, '-e', <<'EOF';
$| = 1;
print scalar <STDIN>;
print STDERR "hi error\n";
ok 9, $? == 0, $?;
# read and error together, both named
-$pid = open3 'WRITE', 'READ', 'READ', $^X, '-e', <<'EOF';
+$pid = open3 'WRITE', 'READ', 'READ', $perl, '-e', <<'EOF';
$| = 1;
print scalar <STDIN>;
print STDERR scalar <STDIN>;
waitpid $pid, 0;
# read and error together, error empty
-$pid = open3 'WRITE', 'READ', '', $^X, '-e', <<'EOF';
+$pid = open3 'WRITE', 'READ', '', $perl, '-e', <<'EOF';
$| = 1;
print scalar <STDIN>;
print STDERR scalar <STDIN>;
# dup writer
ok 14, pipe PIPE_READ, PIPE_WRITE;
$pid = open3 '<&PIPE_READ', 'READ', '',
- $^X, '-e', 'print scalar <STDIN>';
+ $perl, '-e', 'print scalar <STDIN>';
close PIPE_READ;
print PIPE_WRITE "ok 15\n";
close PIPE_WRITE;
# dup reader
$pid = open3 'WRITE', '>&STDOUT', 'ERROR',
- $^X, '-e', 'print scalar <STDIN>';
+ $perl, '-e', 'print scalar <STDIN>';
print WRITE "ok 16\n";
waitpid $pid, 0;
# stdout but putting stdout somewhere else, is a good case because it
# used not to work.
$pid = open3 'WRITE', 'READ', '>&STDOUT',
- $^X, '-e', 'print STDERR scalar <STDIN>';
+ $perl, '-e', 'print STDERR scalar <STDIN>';
print WRITE "ok 17\n";
waitpid $pid, 0;
# dup reader and error together, both named
-$pid = open3 'WRITE', '>&STDOUT', '>&STDOUT', $^X, '-e', <<'EOF';
+$pid = open3 'WRITE', '>&STDOUT', '>&STDOUT', $perl, '-e', <<'EOF';
$| = 1;
print STDOUT scalar <STDIN>;
print STDERR scalar <STDIN>;
waitpid $pid, 0;
# dup reader and error together, error empty
-$pid = open3 'WRITE', '>&STDOUT', '', $^X, '-e', <<'EOF';
+$pid = open3 'WRITE', '>&STDOUT', '', $perl, '-e', <<'EOF';
$| = 1;
print STDOUT scalar <STDIN>;
print STDERR scalar <STDIN>;