Paul Johnson wrote:
On Mon, May 15, 2006 at 04:46:07PM -0400, Tom Allison wrote:


I've got a *bunch* of code that I've been rewriting recently and ran
into a rather weird problem.

it won't fork.

If I write the following:

foreach my $file ( @$files ) {
 my $pid = fork();
 print "$pid --> $file\n";
 [....]
}

I will get an output of:
0 --> file_one
3242 --> file_one
0--> file_two

but no 3243-->file_two.


You don't say anything about what you are trying to do, but when I run
code such as:

$ perl -le 'for (1 .. 2) { my $p = fork; print "[$_][$p]" }'

I see the output just as I expected:

[1][0]
[2][0]
[2][29760]
[1][29759]
[2][0]
[2][29761]

How many files do you have?  And you do realise that this is going to
grow exponentially, don't you?  I'd be surprised if this is actually
what you want.  Perhaps you only want the parent to actually fork?  Have
you read perlipc?


The problem seems to be with a bizarre combination of Solaris, Perl (compiled on gcc and not the solaric compiler), and DBI. I ran into this before but could not replicate it on any Linux boxes.

I've managed to retarded but simple workaround for now and will just sit and watch it for the rest of the day to see that it's working correctly.

The loop that I'm in is supposed to fire every five minutes.
By putting in a condition to make sure it's been 5 minutes since the last loop before I procede, it's working. But not something I planned on doing.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to