I tried to replicate (as simply as possible) the situation you described, which I think would go like this (using "find" as "program C" -- I'm running linux too):
#!/usr/bin/perl # PROGRAM "A" my $pid = fork(); if ( $pid ) { while (1) {sleep 3} } else { exec( "/tmp/junk.perl" ) } __END__ #!/usr/bin/perl # PROGRAM "B" system( "find / -ls > /tmp/junk.find 2>&1" ); # this takes a while __END__

The only way I could make it so that "program C" ("find") kept running after ctl-C stopped "A" was if I added "&" in the system call to run C in the background:
system( "find / -ls > /tmp/junk.find 2>&1 &" );

In this case, of course, the "B" process becomes defunct very soon (it exits after launching "C" in the background), so no amount of signal handling in perl would stop C, unless I took steps to make C's pid available to A, and kill it from there.

You didn't say much about the system call issued in B to launch C; does it background C? Are you sure B is still running when you halt A?

Would it be practical for B to open( C, "process_C |"); or something like that? This way, when B closes the file handle, C is terminated.


In reply to Re: Signal Handling, with system by graff
in thread Signal Handling, with system by dcorbin

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.