Permalink
Browse files

Merge branch 'master' of github.com:exodist/Child

  • Loading branch information...
2 parents 685759f + 4fcfa4a commit 53b73d1c4c63b1055c9128fa9d18ff3846f50a5d @exodist committed Aug 25, 2010
Showing with 24 additions and 9 deletions.
  1. +4 −1 Build.PL
  2. +3 −0 Changes
  3. +2 −1 lib/Child.pm
  4. +11 −3 lib/Child/Link/Proc.pm
  5. +1 −1 lib/Child/Util.pm
  6. +1 −1 t/Child.t
  7. +1 −1 t/Import.t
  8. +1 −1 t/Manage.t
View
@@ -1,4 +1,5 @@
#!/usr/bin/perl
+use 5.006;
use strict;
use warnings;
use Module::Build;
@@ -10,9 +11,11 @@ my $build = Module::Build->new(
create_readme => 1,
requires => {
'POSIX' => 0,
+ 'Exporter' => 5.57,
+ 'perl' => 5.006,
},
build_requires => {
- 'Test::More' => 0,
+ 'Test::More' => 0.88,
},
meta_merge => {
resources => {
View
@@ -0,0 +1,3 @@
+
+
+ - Processes created by fork will have negative pids on Windows (CHORNY)
View
@@ -1,12 +1,13 @@
package Child;
+use 5.006;
use strict;
use warnings;
use Carp;
use Child::Util;
use Child::Link::Proc;
use Child::Link::Parent;
-use base 'Exporter';
+use Exporter 'import';
our $VERSION = "0.007";
our @PROCS;
View
@@ -3,6 +3,7 @@ use strict;
use warnings;
use Carp;
+use Carp;
use Child::Util;
use base 'Child::Link';
@@ -36,6 +37,8 @@ sub unix_exit {
sub _wait {
my $self = shift;
my ( $block ) = @_;
+ #non-blocking to check if process was terminated
+ #blocking to wait until it finishes
unless ( defined $self->exit ) {
my @flags;
require POSIX unless $block;
@@ -46,8 +49,13 @@ sub _wait {
$ret = waitpid( $self->pid, $block ? 0 : &POSIX::WNOHANG );
} while ( $block && !$ret );
return 0 unless $ret;
- croak( "wait returned $ret: No such process " . $self->pid )
- if $ret < 0;
+ if ($^O eq 'MSWin32') {
+ croak( "wait returned $ret: No such process " . $self->pid )
+ if $ret == -1; #forked threads on Win32 have negative pids
+ } else {
+ croak( "wait returned $ret: No such process " . $self->pid )
+ if $ret < 0;
+ }
$self->_exit( $? );
}
return defined($self->exit);
@@ -85,7 +93,7 @@ Check if the child is finished (non-blocking)
=item $proc->wait()
-Wait on the child (blocking)
+Wait until child terminates, destroy remaining zombie process (blocking)
=item $proc->kill($SIG)
View
@@ -3,7 +3,7 @@ use strict;
use warnings;
use Carp qw/croak/;
-use base 'Exporter';
+use Exporter 'import';
our @EXPORT = qw/add_accessors add_abstract/;
sub _abstract {
View
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More;
+use Test::More 0.88;
our $CLASS = 'Child';
require_ok( $CLASS );
View
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More;
+use Test::More 0.88;
our $CLASS = 'Child';
require_ok( $CLASS );
View
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More;
+use Test::More 0.88;
our $CLASS = 'Child';
require_ok( $CLASS );

0 comments on commit 53b73d1

Please sign in to comment.