1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
use strict;
use FileHandle::Unget;
use Test::More tests => 2;
#-------------------------------------------------------------------------------
{
my $out = new FileHandle::Unget;
my $in = new FileHandle::Unget;
CORE::pipe $out, $in or die;
my $pid = fork();
unless(defined $pid)
{
# 1
ok(0, "Couldn't fork");
# 2
ok(0, "Couldn't get info from child");
exit;
}
# In parent
if ($pid)
{
close $in;
# 1
ok(1, 'Fork succeeded');
local $/ = undef;
my $results = <$out>;
# 2
is($results,"Some info from the child\nSome more\n", 'Child output');
exit;
}
# In child
else
{
print $in "Some info from the child\nSome more\n";
exit;
}
}
|