#!/bin/perl -w
use POSIX;   #for the W functions

$SIG{CHLD} = 'death_of_child';

$pid = fork();
defined $pid or die "$0: $!";

if ($pid == 0) {
	#Arrive here if I am the child.
	sleep 3;
	exit 0;
}

#Arrive here if I am the parent.
#Copy the standard input to the standard output until the death of child.
while (($c = getc()) ne '') {
	print $c;
}

sub death_of_child {
	print "My child is dead.\n";
	exit 0;
}
