Subject: | Re: Bug in MCE when cleaning up child processes |
Date: | Sun, 13 Apr 2014 21:29:02 -0700 |
To: | bug-MCE [...] rt.cpan.org |
From: | Shawn Halpenny <paxunix [...] gmail.com> |
On Sun, Apr 13, 2014 at 9:13 PM, Shawn Halpenny <paxunix@gmail.com> wrote:
Show quoted text
> Naturally, as soon as I sent off that email, I noticed I had mistakenly
> NOT imported MCE::Signal before my other MCE import. Once I did that, all
> child processes were killed just fine, as expected.
>
>
Actually, I take that back. There does seem to be some odd behaviour. As
mentioned in the perldoc for MCE::Signal:
-setpgrp - Calls setpgrp to set the process group for the process
Specify this option to ensure all workers terminate
when reading STDIN like so:
cat big_input_file | ./mce_script.pl | head -10
This works fine without the -setpgrp option:
./mce_script.pl < big_input_file | head -10
So, taking this example:
#!perl
use MCE::Signal qw(-setpgrp);
use MCE::Loop;
MCE::Loop::init {
chunk_size => 1,
max_workers => 20,
};
mce_loop {
my ($mce, $chunkRef, $chunkId) = @_;
print("$chunkRef->[0]");
system("sleep 1000");
} <>;
And running it:
example.pl < somefile
^C during this kills all child processes as expected.
However ^C during:
cat somefile | example.pl
does nothing at all (neither does SIGQUIT or SIGSUSP).
--ShawnH