Skip to content
Browse files

Processes created by fork will have negative pids on Windows

  • Loading branch information...
1 parent 2d46bc3 commit 4fcfa4aac5f4bc98bc6dc43fdb3c6807e72205e6 @chorny chorny committed with
Showing with 12 additions and 2 deletions.
  1. +3 −0 Changes
  2. +9 −2 lib/Child/Link/Proc.pm
View
3 Changes
@@ -0,0 +1,3 @@
+
+
+ - Processes created by fork will have negative pids on Windows (CHORNY)
View
11 lib/Child/Link/Proc.pm
@@ -36,6 +36,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 +48,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);

0 comments on commit 4fcfa4a

Please sign in to comment.
Something went wrong with that request. Please try again.