use Win32::OLE('in'); use POSIX":sys_wait_h"; my $pid = fork(); my $check; die "can't fork:$?" unless(defined $pid); if ($pid != 0) { print "I am the parent\n"; my $flag = 0; while ($flag == 0) { $check = waitpid($pid,&WNOHANG); print "Waitpid returned $check\n"; if ($check > 0) { print "Parent caught death of child $pid\n"; $flag = 1; } else { sleep 1; print "Not yet caught\n"; } } print "Parent is exiting\n"; } else { print "I am the child\n"; sleep 3; print "Child is exiting\n"; exit (0); }