$|++; # flush buffers; # set a common variable to 1, the parent will leave its # copy alone but the child will increment its copy. my $in++; defined(my $pid = fork) or die "Can't fork $!"; if ($pid) { # do parent stuff print "I am the parent!\n\n"; sleep 2; print "I am going to count to 10\n"; for (1..10) { print "$_ Do as I say!\n"; sleep $in; } print "You're grounded!\n"; # kill INT, $pid; # uncomment this to kill child process } else { # do child stuff sleep $in; print "I am the child!\n\n"; sleep $in++; print "No!\n"; sleep $in++; print "No!\n"; sleep $in++; print "No!\n"; sleep $in++; print "No!\n"; sleep $in++; print "I am not deaf, I'm ignoring you!\n"; } die "End of process \$pid = $pid \n\n";