The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
Changes 99106
MANIFEST 03
META.json 076
META.yml 11
Makefile.PL 11
dist.ini 06
lib/System/Command/Reaper.pm 22
lib/System/Command.pm 617
pod2htmd.tmp 02
pod2htmi.tmp 02
t/000-report-versions-tiny.t 02
t/10-command.t 07
12 files changed (This is a version diff) 109225
@@ -1,141 +1,148 @@
 Revision history for System-Command
 
+1.110 Wed Aug 27 2014
+    [ENHANCEMENTS]
+    - the 'setpgrp' option can be used to enable/disable the call to
+      setpgrp() in the spawned process
+    [TESTS]
+    - t/10-command.t now ignores environment variables set by ConEmu
+
 1.109 Wed Jul 2 2014
-        [BUG FIX]
-        - fix the test failures on Solaris, thanks to Wolfgang Pecho
-          (RT #82857). The reaper code was actually buggy (since v1.03!)
-          and only accidentally worked on platforms where WNOHANG == 1
-          (which was most of them)
+    [BUG FIX]
+    - fix the test failures on Solaris, thanks to Wolfgang Pecho
+      (RT #82857). The reaper code was actually buggy (since v1.03!)
+      and only accidentally worked on platforms where WNOHANG == 1
+      (which was most of them)
 
 1.108 Wed Feb 26 2014
-        [ENHANCEMENTS]
-        - the trace option makes it possible to see exactly which commands
-          were spawned, with their options (including environment)
-        [DOCUMENTATION]
-        - style fixes
+    [ENHANCEMENTS]
+    - the 'trace' option makes it possible to see exactly which commands
+      were spawned, with their options (including environment)
+    [DOCUMENTATION]
+    - style fixes
 
 1.107 Sun Oct 20 2013
-        [ENHANCEMENTS]
-        - zombies do not exist under Win32, so no need to warn about
-          waitpid return value (many thanks to MITHALDU for his
-          continued help in testing on this platform)
-        [DOCUMENTATION]
-        - removed duplicated NAME section
-        [FUN]
-        - more zombie quotes in System::Command::Reaper comments
+    [ENHANCEMENTS]
+    - zombies do not exist under Win32, so no need to warn about
+      waitpid return value (many thanks to MITHALDU for his
+      continued help in testing on this platform)
+    [DOCUMENTATION]
+    - removed duplicated NAME section
+    [FUN]
+    - more zombie quotes in System::Command::Reaper comments
 
 1.106 Sat Oct 12 2013
-        [ENHANCEMENTS]
-        - brought back System::Command::Reaper, which properly deals
-          with zombies
-        - execute the command in its own process group whenever possible
-          (thanks to Vincent Pit)
-        [TESTS]
-        - test for the zombie processes is not TODO anymore
-        - tests for the timely destruction of the reaper are back
+    [ENHANCEMENTS]
+    - brought back System::Command::Reaper, which properly deals
+      with zombies
+    - execute the command in its own process group whenever possible
+      (thanks to Vincent Pit)
+    [TESTS]
+    - test for the zombie processes is not TODO anymore
+    - tests for the timely destruction of the reaper are back
 
 1.105 Sat Oct 5 2013
-        [TESTS]
-        - add a TODO test for the zombie processes created in certain cases
-        - various other test improvements
+    [TESTS]
+    - add a TODO test for the zombie processes created in certain cases
+    - various other test improvements
 
 1.104 Thu Sep 12 2013
-        [ENHANCEMENTS]
-        - fixed for Perl versions < 5.8.9
-        [DOCUMENTATION]
-        - minor documentation improvements
-        [PACKAGING]
-        - switch to Dist::Zilla for maintaining the distribution
+    [ENHANCEMENTS]
+    - fixed for Perl versions < 5.8.9
+    [DOCUMENTATION]
+    - minor documentation improvements
+    [PACKAGING]
+    - switch to Dist::Zilla for maintaining the distribution
 
 1.103 Mon Jul 29 2013
-        [ENHANCEMENTS]
-        - rewrote the _spawn code to work properly under Plack
-        - version 1.100 and 1.102 re-introduced old bugs: they
-          have been squished again, and tests fixed to prevent
-          re-re-introduction
+    [ENHANCEMENTS]
+    - rewrote the _spawn code to work properly under Plack
+    - version 1.100 and 1.102 re-introduced old bugs: they
+      have been squished again, and tests fixed to prevent
+      re-re-introduction
 
 1.102 Fri Jul 26 2013
-        [ENHANCEMENTS]
-        - ported an older fix from Git::Repository, to make System::Command
-          work with modules that do bad things to STDIN, STDOUT and STDERR
-          (thanks to Todd Rinaldo for his 2010 patch to Git::Repository)
-          [work done during the patch -p0 hackathon]
+    [ENHANCEMENTS]
+    - ported an older fix from Git::Repository, to make System::Command
+      work with modules that do bad things to STDIN, STDOUT and STDERR
+      (thanks to Todd Rinaldo for his 2010 patch to Git::Repository)
+      [work done during the patch -p0 hackathon]
 
 1.101 Thu Jul 11 2013
-        [TESTS]
-        - various minor test improvements (thanks to Oleg Gashev and mokko)
-        [DOCUMENTATION]
-        - minor documentation improvements
+    [TESTS]
+    - various minor test improvements (thanks to Oleg Gashev and mokko)
+    [DOCUMENTATION]
+    - minor documentation improvements
 
 1.100 Sun Apr 14 2013
-        [ENHANCEMENTS]
-        - use a IPC::Run-based implementation on Win32
-        - thanks to a lot of testing help from Christian Walde (MITHALDU)
-          the test suite passes on Win32
-        - while working on this, we established that kill 0, $pid is broken
-          under Win32 (reported to the perl5-porters mailing-list via
-          <op.wvi2ygw1ydyjqt@digitizedsqueak.lancs.ac.uk>)
+    [ENHANCEMENTS]
+    - use a IPC::Run-based implementation on Win32
+    - thanks to a lot of testing help from Christian Walde (MITHALDU)
+      the test suite passes on Win32
+    - while working on this, we established that kill 0, $pid is broken
+      under Win32 (reported to the perl5-porters mailing-list via
+      <op.wvi2ygw1ydyjqt@digitizedsqueak.lancs.ac.uk>)
 
 1.09 Sun Dec  9 2012
-        [ENHANCEMENTS]
-        - list all dependencies and the github public repo in the META files
-          (RT #81302)
-        - use Symbol::gensym to create anonumous GLOBs (github #4)
+    [ENHANCEMENTS]
+    - list all dependencies and the github public repo in the META files
+      (RT #81302)
+    - use Symbol::gensym to create anonumous GLOBs (github #4)
 
 1.08 Mon Nov 26 2012
-        [ENHANCEMENTS]
-        - remove a superfluous eval {} that was hiding open3 exception
-          (RT #80171)
-        - set a handler for the PIPE signal only if Perl knows about it
+    [ENHANCEMENTS]
+    - remove a superfluous eval {} that was hiding open3 exception
+      (RT #80171)
+    - set a handler for the PIPE signal only if Perl knows about it
 
 1.07 Wed Apr 18 03:00:50 CEST 2012
-        [TESTS]
-        - t/20-zombie.t sometimes failed because of a race condition.
-          I'm now testing my assumptions, make the test in question a
-          little bit useless, and closing RT #74959
+    [TESTS]
+    - t/20-zombie.t sometimes failed because of a race condition.
+      I'm now testing my assumptions, make the test in question a
+      little bit useless, and closing RT #74959
 
 1.06 Sun Jan  8 00:36:40 CET 2012
-        [ENHANCEMENTS]
-        - add tests that show that I don't understand what I'm doing
-          with STDIN/OUT/ERR, and remove the offending code (RT #73614)
+    [ENHANCEMENTS]
+    - add tests that show that I don't understand what I'm doing
+      with STDIN/OUT/ERR, and remove the offending code (RT #73614)
 
 1.05 Fri Jul  8 09:16:25 CEST 2011
-        [ENHANCEMENTS]
-        - make spawn() work properly with subclasses
+    [ENHANCEMENTS]
+    - make spawn() work properly with subclasses
 
 1.04 Tue Jun  7 00:47:13 CEST 2011
-        [ENHANCEMENTS]
-        - allow removing variables from the environment by setting
-          keys with an 'undef' value in the 'env' option
-        [TESTS]
-        - tests for the import options
-        - added tests that were created for version 1.02 to the MANIFEST
+    [ENHANCEMENTS]
+    - allow removing variables from the environment by setting
+      keys with an 'undef' value in the 'env' option
+    [TESTS]
+    - tests for the import options
+    - added tests that were created for version 1.02 to the MANIFEST
 
 1.03 Thu Mar 17 22:47:38 CET 2011
-        [ENHANCEMENTS]
-        - removed all the System::Command::Reaper logic which, while
-          being really nice, didn't actually add any value, and made
-          things more complex
+    [ENHANCEMENTS]
+    - removed all the System::Command::Reaper logic which, while
+      being really nice, didn't actually add any value, and made
+      things more complex
 
 1.02 Tue Mar 15 20:27:29 CET 2011
-        [FEATURES]
-        - new method is_terminated() allows to inquire about the child
-          process state
-        [ENHANCEMENTS]
-        - added a relatively sane behaviour when a SIGCHLD handler exists
-        - warns when such a SIGCHLD handler may prevent prevent the
-          capture of status information at the death of a child process
-        - added a -quiet option to silence the warning
-        - ported fixes from Git::Repository to work with modules that do
-          bad things to STDIN, STDOUT and STDERR (thanks to Todd Rinaldo)
+    [FEATURES]
+    - new method is_terminated() allows to inquire about the child
+      process state
+    [ENHANCEMENTS]
+    - added a relatively sane behaviour when a SIGCHLD handler exists
+    - warns when such a SIGCHLD handler may prevent prevent the
+      capture of status information at the death of a child process
+    - added a -quiet option to silence the warning
+    - ported fixes from Git::Repository to work with modules that do
+      bad things to STDIN, STDOUT and STDERR (thanks to Todd Rinaldo)
 
 1.01 Tue Feb  1 00:13:33 CET 2011
-        [FEATURES]
-        - new shortcut class method: spawn()
+    [FEATURES]
+    - new shortcut class method: spawn()
 
 1.00 Wed Jan 20 00:50:17 CET 2011
-        [FEATURES]
-        - Generic version of the Git::Repository::Command process spawner
-        [BUGS]
-        - No work has been put on the Win32 version yet.
+    [FEATURES]
+    - Generic version of the Git::Repository::Command process spawner
+    [BUGS]
+    - No work has been put on the Win32 version yet.
 
@@ -2,12 +2,15 @@
 Changes
 LICENSE
 MANIFEST
+META.json
 META.yml
 Makefile.PL
 README
 dist.ini
 lib/System/Command.pm
 lib/System/Command/Reaper.pm
+pod2htmd.tmp
+pod2htmi.tmp
 t/00-load.t
 t/000-report-versions-tiny.t
 t/01-load.t
@@ -0,0 +1,76 @@
+{
+   "abstract" : "Object for running system commands",
+   "author" : [
+      "Philippe Bruhat (BooK) <book@cpan.org>"
+   ],
+   "dynamic_config" : 0,
+   "generated_by" : "Dist::Zilla version 5.016, CPAN::Meta::Converter version 2.133380",
+   "license" : [
+      "perl_5"
+   ],
+   "meta-spec" : {
+      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+      "version" : "2"
+   },
+   "name" : "System-Command",
+   "prereqs" : {
+      "configure" : {
+         "requires" : {
+            "ExtUtils::MakeMaker" : "6.30"
+         }
+      },
+      "develop" : {
+         "requires" : {
+            "Pod::Coverage::TrustPod" : "0",
+            "Test::CPAN::Meta" : "0",
+            "Test::Pod" : "1.41",
+            "Test::Pod::Coverage" : "1.08",
+            "version" : "0.9901"
+         }
+      },
+      "runtime" : {
+         "requires" : {
+            "Carp" : "0",
+            "Cwd" : "0",
+            "Data::Dumper" : "0",
+            "Fcntl" : "0",
+            "IO::Handle" : "0",
+            "IPC::Run" : "0",
+            "List::Util" : "0",
+            "POSIX" : "0",
+            "Scalar::Util" : "0",
+            "Symbol" : "0",
+            "constant" : "0",
+            "perl" : "5.006",
+            "strict" : "0",
+            "warnings" : "0"
+         }
+      },
+      "test" : {
+         "recommends" : {
+            "Test::Command" : "0",
+            "Test::Output" : "0"
+         },
+         "requires" : {
+            "File::Find" : "0",
+            "File::Spec" : "0",
+            "File::Temp" : "0",
+            "Test::More" : "0.88"
+         }
+      }
+   },
+   "release_status" : "stable",
+   "resources" : {
+      "bugtracker" : {
+         "mailto" : "bug-system-command@rt.cpan.org",
+         "web" : "http://rt.cpan.org/NoAuth/Bugs.html?Dist=System-Command"
+      },
+      "repository" : {
+         "type" : "git",
+         "url" : "http://github.com/book/System-Command.git",
+         "web" : "http://github.com/book/System-Command"
+      }
+   },
+   "version" : "1.110"
+}
+
@@ -34,4 +34,4 @@ requires:
 resources:
   bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=System-Command
   repository: http://github.com/book/System-Command.git
-version: '1.109'
+version: '1.110'
@@ -41,7 +41,7 @@ my %WriteMakefileArgs = (
     "File::Temp" => 0,
     "Test::More" => "0.88"
   },
-  "VERSION" => "1.109",
+  "VERSION" => "1.110",
   "test" => {
     "TESTS" => "t/*.t"
   }
@@ -18,8 +18,14 @@ match    = cover_db
 
 [AutoPrereqs]
 
+[Prereqs / TestRecommends]
+Test::Command =
+Test::Output  =
+
 [ReportVersions::Tiny]
 
+[MetaJSON]
+
 [MetaResources]
 repository.web    = http://github.com/book/System-Command
 repository.url    = http://github.com/book/System-Command.git
@@ -1,5 +1,5 @@
 package System::Command::Reaper;
-$System::Command::Reaper::VERSION = '1.109';
+$System::Command::Reaper::VERSION = '1.110';
 use strict;
 use warnings;
 use 5.006;
@@ -102,7 +102,7 @@ System::Command::Reaper - Reap processes started by System::Command
 
 =head1 VERSION
 
-version 1.109
+version 1.110
 
 =head1 SYNOPSIS
 
@@ -1,5 +1,5 @@
 package System::Command;
-$System::Command::VERSION = '1.109';
+$System::Command::VERSION = '1.110';
 use warnings;
 use strict;
 use 5.006;
@@ -56,7 +56,7 @@ for my $attr (qw( cmdline )) {
 # REALLY PRIVATE FUNCTIONS
 # a sub-process spawning function
 my $_spawn = sub {
-    my (@cmd) = @_;
+    my ($o, @cmd) = @_;
     my $pid;
 
     # setup filehandles
@@ -125,7 +125,7 @@ my $_spawn = sub {
                 close $err;
 
                 # setup process group if possible
-                setpgrp 0, 0 if $Config{d_setpgrp};
+                setpgrp 0, 0 if $o->{setpgrp} && $Config{d_setpgrp};
 
                 # close $stat_w on exec
                 my $flags = fcntl( $stat_w, F_GETFD, 0 )
@@ -192,7 +192,7 @@ sub new {
     my ( $class, @cmd ) = @_;
 
     # split the args
-    my @o;
+    my @o = { setpgrp => 1 };
     @cmd = grep { !( ref eq 'HASH' ? push @o, $_ : 0 ) } @cmd;
 
     # merge the option hashes
@@ -228,7 +228,7 @@ sub new {
     }
 
     # start the command
-    my ( $pid, $in, $out, $err ) = eval { $_spawn->(@cmd); };
+    my ( $pid, $in, $out, $err ) = eval { $_spawn->( $o, @cmd ); };
 
     # FIXME - better check error conditions
     if ( !defined $pid ) {
@@ -292,7 +292,7 @@ System::Command - Object for running system commands
 
 =head1 VERSION
 
-version 1.109
+version 1.110
 
 =head1 SYNOPSIS
 
@@ -384,6 +384,17 @@ On some systems, some commands may close standard input on startup,
 which will cause a SIGPIPE when trying to write to it. This will raise
 an exception.
 
+=item C<setpgrp>
+
+By default, the spawned process is made the leader of its own process
+group using C<setpgrp( 0, 0 )> (if possible). This enables sending a
+signal to the command and all its child processes at once:
+
+    # negative signal is sent to the process group
+    kill -SIGKILL, $cmd->pid;
+
+Setting the C<setpgrp> option to a false value disables this behaviour.
+
 =item C<trace>
 
 The C<trace> option defines the trace settings for System::Command.
@@ -0,0 +1,2 @@
+
+.
@@ -0,0 +1,2 @@
+
+.
@@ -64,7 +64,9 @@ eval { $v .= pmver('Pod::Coverage::TrustPod','any version') };
 eval { $v .= pmver('Scalar::Util','any version') };
 eval { $v .= pmver('Symbol','any version') };
 eval { $v .= pmver('Test::CPAN::Meta','any version') };
+eval { $v .= pmver('Test::Command','any version') };
 eval { $v .= pmver('Test::More','0.88') };
+eval { $v .= pmver('Test::Output','any version') };
 eval { $v .= pmver('Test::Pod','1.41') };
 eval { $v .= pmver('Test::Pod::Coverage','1.08') };
 eval { $v .= pmver('constant','any version') };
@@ -78,6 +78,9 @@ my @tests = (
             input => ''
             }
     },
+    {   cmdline => [ $^X, $name, { env => { 'TO_BE_DELETED' => '' } } ],
+        options => { env => { 'TO_BE_DELETED' => '' } }
+    },
 );
 my @fail = (
     {   cmdline =>
@@ -120,6 +123,9 @@ for my $t ( @tests, @fail ) {
         }
     }
 
+    # default option: setpgrp
+    $t->{options}{setpgrp} = 1
+        if !exists $t->{options}{setpgrp};
     is_deeply( [ $cmd->cmdline ],
         [ grep { !ref } @{ $t->{cmdline} } ], 'cmdline' );
     is_deeply( $cmd->options, $t->{options}, 'options' );
@@ -133,6 +139,7 @@ for my $t ( @tests, @fail ) {
     delete $env->{$_}
         for grep { !defined $t->{options}{env}{$_} }
         keys %{ $t->{options}{env} || {} };
+    delete $env->{$_} for grep /^CONEMU/, keys %ENV;
     my $info;
     eval $output;
     my $w32env = {};