I am seeing some odd behavior from my code (below), and I'd like some help understanding it. My code is based off the Perl Cookbook Recipe 16.12.

When I first ran the code and hit CTRL C, the SIGINT killed all of the children processes, just like it was supposed to. Then I began having errors that said: cannot create semaphore. No space left on device or something very similar to that. In the process of debugging that, I noticed that CTRL-C no longer killed my child processes.

I'm still not sure I've completely understood what was causing me to run out of shared memory space, although my theory is: I was killing the code after just a few iterations, without using die. And I don't understand why my SIGINT trap isn't killing the child processes.

I appreciate any advice or help anyone can offer.

P.S. If it matters: I'm running this code on Linux Mint 9 and Perl 5.10.1

use strict; # use warnings; use Parallel::ForkManager; use LWP::Simple; use IPC::Shareable; my $max_forks = 100; my $forkman = Parallel::ForkManager->new( $max_forks ); my $count=0; my %data; open (URLS, "<url-list.txt"); my $count_handle = tie $count, 'IPC::Shareable', undef, {destroy => 1 +}; $SIG{INT} = sub { die "$$ dying\n" }; print "Parent PID is $$\n"; while( my $url = <URLS> ) { $forkman->start and next; chomp($url); fetch($url); $forkman->finish; } $forkman->wait_all_children; close URLS; print "\n\nDONE.\n"; sub fetch { #html get to test parallel forks my $target = shift; $count_handle->shlock(); my $thiscount = $count++; $count_handle->shunlock(); my @header = head("http://$target"); print "PID: $$, $thiscount: $target - @header\n"; }

In reply to Shared Memory and Child Processes by Mad_Mac

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.