Created
November 29, 2011 07:12
-
-
Save schwern/1403823 to your computer and use it in GitHub Desktop.
fork.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Test::More tests => 4; | |
pass("Before fork"); | |
my $tb = Test::More->builder; | |
my $pid = fork; | |
if( ! defined $pid ) { # failed | |
die "fork() failed: $!"; | |
} | |
elsif( $pid ) { # parent | |
pass("Parent"); | |
} | |
else { # child | |
sleep 1; | |
# Increment the counter to take into account what was | |
# run by the parent. | |
$tb->current_test($tb->current_test + 1); | |
subtest "child" => sub { | |
pass("Child"); | |
}; | |
exit; | |
} | |
# Increment the counter to take into account what was run by the child | |
$tb->current_test($tb->current_test + 1); | |
wait; | |
pass("After fork"); | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment