#!/usr/bin/perl -w use strict; my $pid; my $output; defined( $pid = fork ) or die "Unable to fork!\n$!\n"; if ( $pid ) { print "Hi! I'm a parent! This is my child $pid\n"; while ( ( $output = kill( 0, $pid ) ) > 0 ) { print "I'm going to wait for my child to die...\n"; print $output, "\n"; sleep 2; } } else { print "I'm a kid! My name is $$\n"; print "I'm going to die now\n"; }