Subject: | undef warning under perl -w when fork ENOMEM |
Date: | Tue, 04 May 2010 09:46:55 +1000 |
To: | bug-IPC-Run [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
With recent debian i386 perl 5.10.1 and IPC::Run 0.89, if fork() fails
due to ENOMEM then IPC::Run::run() prints a warning. For example the
program foo.pl below run as
perl -w foo.pl
gets
Use of uninitialized value in length at /usr/share/perl5/IPC/Run.pm line 3157.
where I hoped it would not do that, but only throw "Cannot allocate
memory during fork" or whatever.
The size of process that cannot fork of course depends on how much ram
and swap you've got. The 100e6 / 4 in the program uses up about
100Mbytes on a 32-bit system, increase as necessary :-).
#!/usr/bin/perl -w
use strict;
use warnings;
use IPC::Run;
use Data::Dumper;
my @x;
$#x = 100e6 / 4;
print scalar(@x),"\n";
my $pid = fork();
print Data::Dumper->new([\$pid],['pid'])->Dump;
my $out;
IPC::Run::run (['echo', 'hello']);
print "done\n";
exit 0;