#!/fellow/monks.pl On both AIX and Mandrake Linux, I'm experiencing a problem where programs spawned from within a perl script doesn't get killed when the parent dies. Yeah, children should live longer than their parents, but not in a perl script, I would think. Here's my code (and I've tried many different ways of opening tail)..
So touch testlog.txt, run the script, and start a 2nd session. Do a ps -ef and you'll see the process running, along with the spawned tail. Kill the parent, and the child becomes almost orphaned, using the inittab as it's parent. How can I kill the child when the parent dies, or at least spawn the child that it's dependant on the parent's survival??#!/usr/bin/perl open (HTML, "-|") or exec("tail","-f","testlog.txt"); print while <HTML>;
[gmassyn@apt01m04 gmassyn]$ ps -ef |grep test gmassyn 7755 7712 0 21:57 pts/0 00:00:00 /usr/bin/perl ./testb. +pl gmassyn 7756 7755 0 21:57 pts/0 00:00:00 tail -f testlog.txt gmassyn 7758 7712 0 21:57 pts/0 00:00:00 grep test [gmassyn@apt01m04 gmassyn]$ kill -9 7755 [gmassyn@apt01m04 gmassyn]$ [1]+ Killed ./testb.pl [gmassyn@apt01m04 gmassyn]$ ps -ef |grep test gmassyn 7756 1 0 21:57 pts/0 00:00:00 tail -f testlog.txt gmassyn 7764 7712 0 21:57 pts/0 00:00:00 grep test [gmassyn@apt01m04 gmassyn]$
Thanks!
|\/| _. _ _ ._
www. | |(_|_>_>\/| | .net
/
The more I learn the more I realise I don't know.In reply to Automatically killing a child by Massyn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |