#!/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 th +is. 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 run +s. Need child to exit when parent exits. kill TERM, $cpid; exit(0);
In reply to Deamon: Need Child to exit if parent dies by aennen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |