Hi perl gurus, I have a setup wherein a perl script is configured as a service inetd.conf (i.e., the perl script is spawned when I make a telnet/tcp connection to the corresponding tcp port defined in inetd.conf). The perl script in turn starts up remsh onto a different host
open(RCMD, "remsh $h -l $u $script |") || die $!; while (<RCMD>) { print $_; }
So, the intent is that a user or application makes a connection to the inetd port (for example, telnet localhost 9876), inetd spawns the perl script, which in turn runs remsh. The perl script has cleanup sub-routine setup for TERM, HUP, QUIT, PIPE signals. The setup works ok except that when the calling telnet/tcp process exits, the perl script is not getting any signal or any indication that the calling process has exited. The only time we get an indication that the calling process has exited is when the remsh returns some data to be written to STDOUT, at which time a SIGPIPE is signalled. I checked inetd code to see if it monitors the active socket; inetd just passes the control of the active socket essentially to the perl script (using dup2 and execv). An immediate indication I get that the calling process has exited is that the child remsh process either exits (HP-UX) or becomes defunct (Tru64) - This happens when I dont use the -n option for remsh. To cut a long story short, do you have any pointers on how I can detect that the calling process has exited ? Any different ways in which I can call remsh ? Also, is it possible for the perl process to check if the stdout has been closed without writing any data to the stdout ?

In reply to inetd spawned perl problem by vasu

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.