Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the MCE CPAN distribution.

Report information
The Basics
Id: 94710
Status: resolved
Priority: 0/
Queue: MCE

People
Owner: Nobody in particular
Requestors: paxunix [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.512



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
Subject: Re: [rt.cpan.org #94710] Re: Bug in MCE when cleaning up child processes
Date: Mon, 14 Apr 2014 12:26:52 -0400
To: bug-MCE [...] rt.cpan.org
From: Mario Roy <marioeroy [...] gmail.com>
Hi Shawn, Thank you for the report. The system function in Perl ignores SIGINT and SIGQUIT. These 2 signals are sent to the command being executed via system() but not back to the underlying Perl script. MCE::Signal provides sys_cmd for this very reason. The sys_cmd function will ensure the Perl script receives the same signal in order to raise an exception immediately after the system call. (do not pass -setpgrp). use MCE::Signal qw(sys_cmd); use MCE::Loop; MCE::Loop::init { chunk_size => 1, max_workers => 20, }; mce_loop { my ($mce, $chunkRef, $chunkId) = @_; print("$chunkRef->[0]"); sys_cmd("sleep 1000"); } \*STDIN; Thank you for the tip on kill(<signal>, -getpgrp()). Will check -setpgrp, was expecting that to work. In the meantime, the above should work for you. Regards, Mario
Subject: Re: [rt.cpan.org #94710] Re: Bug in MCE when cleaning up child processes
Date: Tue, 15 Apr 2014 00:59:30 -0400
To: bug-MCE [...] rt.cpan.org
From: Mario Roy <marioeroy [...] gmail.com>
Hi Shawn, Committed revision 511 in SVN. That is an update to MCE::Signal.pm. https://code.google.com/p/many-core-engine-perl/source/detail?r=511 The -setpgrp option is no longer necessary for the upcoming MCE 1.512 release. Remember to call sys_cmd instead of the internal system function. use MCE::Signal qw(sys_cmd); use MCE; cat somefile | example.pl | head example.pl < somefile | head Thank you for the tip on getpgrp(). That was helpful. Regards, Mario
Subject: Re: [rt.cpan.org #94710] Re: Bug in MCE when cleaning up child processes
Date: Tue, 15 Apr 2014 01:45:01 -0400
To: bug-MCE [...] rt.cpan.org
From: Mario Roy <marioeroy [...] gmail.com>
Committed revision 512 in SVN. Added additional clarity to the perldoc for MCE::Signal on -setpgrp. Basically, do not specify -setpgrp when calling external commands via sys_cmd() inside your MCE script. https://code.google.com/p/many-core-engine-perl/source/detail?r=512 One condition fails when specifying -setpgrp. Testing was done with "sleep 1" for testing with | head. use MCE::Signal qw(-setpgrp sys_cmd); use MCE; cat somefile | example.pl | head (pass, does not wait to exit until the entire file is read and processed) example.pl < somefile | head (pass) cat somefile | example.pl (fail, ctrl-c) example.pl < somefile (pass) All is passing when -setpgrp is not specified. use MCE::Signal qw(sys_cmd); use MCE; Regards, Mario
Subject: Re: [rt.cpan.org #94710] Re: Bug in MCE when cleaning up child processes
Date: Tue, 15 Apr 2014 19:07:52 -0400
To: bug-MCE [...] rt.cpan.org
From: Mario Roy <marioeroy [...] gmail.com>
Am happy to report that this has been address with the latest SVN revision 513. All conditions are passing. The -setpgrp option for MCE::Signal is no longer necessary, even for use with Daemon::Control. Piping input into a MCE script works equally well wether setpgrp is specified or not. -mario
MCE 1.512 has been released on CPAN to address this bug.