aennen has asked for the wisdom of the Perl Monks concerning the following question:
#!/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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Deamon: Need Child to exit if parent dies
by JavaFan (Canon) on Jan 04, 2010 at 22:42 UTC | |
|
Re: Deamon: Need Child to exit if parent dies
by MidLifeXis (Monsignor) on Jan 04, 2010 at 22:38 UTC | |
by bot403 (Beadle) on Jan 05, 2010 at 20:33 UTC | |
|
Re: Daemon: Need Child to exit if parent dies
by shmem (Chancellor) on Jan 04, 2010 at 23:00 UTC | |
by JavaFan (Canon) on Jan 05, 2010 at 11:43 UTC |