delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/07/20/16:32:30

X-Spam-Check-By: sourceware.org
Message-ID: <3295.130.240.136.130.1153427529.squirrel@pinus.tt.luth.se>
In-Reply-To: <20060720193134.GB14980@trixie.casa.cgf.cx>
References: <20060713180601 DOT GA3872 AT efn DOT org> <B7392353E4C4DE4ABC4EC255DB4CA040034716A2 AT EXCHVS1 DOT spimageworks DOT com> <20060719100824 DOT GD18664 AT calimero DOT vinschen DOT de> <20060720193134 DOT GB14980 AT trixie DOT casa DOT cgf DOT cx>
Date: Thu, 20 Jul 2006 22:32:09 +0200 (CEST)
Subject: Re: Perl failure
From: "Bengt-Arne Fjellner" <Bengt-Arne DOT Fjellner AT ltu DOT se>
To: cygwin AT cygwin DOT com
User-Agent: SquirrelMail/1.4.5
MIME-Version: 1.0
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Christopher Faylor skrev:
> On Wed, Jul 19, 2006 at 12:08:24PM +0200, Corinna Vinschen wrote:
>>On Jul 18 17:45, Bruce Dobrin wrote:
>>> Hi,
>>> I stripped down the code to a small testable bit.  The problem seems to
>>> occur when I reach 256 forks on a cygwin1.5.18 or 19 but not on my
>>> cygwin1.5.5. win2k system.  The original code give the forked process
>>> time to finish,  but it still looks like it eats it after about 256
>>> iterations  ( it actually failed between 259 and 252 iterations,  but
>>> it's pretty complicated so I'm not sure what else was happening).
>>>
>>> Here is my test code:
>>> dobrin AT tiburon:/tmp> cat test8.pl
>>> ################
>>> #!/usr/bin/perl -w
>>>
>>> use strict;
>>> my $pid;
>>>
>>> foreach my $incr (`seq 1 1 800`) {
>>>
>>>                     unless (defined ($pid = fork)) {
>>>                          die " cannot fork $!";
>>>                      }
>>>                     unless ($pid) {
>>>                       print " the sequence is $incr \n";
>>>                       exit;
>>>                     }
>>>              print "pid is $pid\n";
>>>            }
>>>
>>> ###############
>>>
>>> The error here is :
>>> cannot fork Resource temporarily unavailable at ./test8.pl line 11.
>>> panic: MUTEX_LOCK (45) [op.c:354].

Suggestion install a handler for sigchld and reap them as they die
see below.
Warning dont do to much in the handler.
see man perlvar for %SIG

#!/usr/bin/perl

use warnings;
use strict;
my $pid;

sub foo{
    print ("process ",wait," died\n");
}

foreach my $incr (`seq 1 1 8`) {
    $SIG{CHLD}=\&foo;
    unless (defined ($pid = fork)) {
	die " cannot fork $!";
    }
    unless ($pid) {
	print " the sequence is $incr \n";
	exit;
    }
    print "pid is $pid\n";
}

###############

-- 
Bengt-Arne Fjellner




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019