#!/usr/bin/perl #heart beat funtion, infinite sub beat() { print "IM THE CHILD\n"; while(1) { print "Beat $i\n"; sleep 2; } exit(0); } #put heartbeat in background so whatever app is doing doesnt effect this. my $cpid = fork(); if ($cpid == 0) { &beat(); } ## parent stuff here ..... print "IM THE PARENT\n"; sleep 10; print "Bye\n"; #I can kill the child directly but if parent is killed child still runs. Need child to exit when parent exits. kill TERM, $cpid; exit(0);