#!/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)..

#!/usr/bin/perl open (HTML, "-|") or exec("tail","-f","testlog.txt"); print while <HTML>;
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??
[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.
- Albert Einstein

In reply to Automatically killing a child by Massyn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.