Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Processes created by fork will have negative pids on Windows
  • Loading branch information
chorny authored and exodist committed Aug 24, 2010
1 parent 2d46bc3 commit 4fcfa4a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -0,0 +1,3 @@


- Processes created by fork will have negative pids on Windows (CHORNY)
11 changes: 9 additions & 2 deletions lib/Child/Link/Proc.pm
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 4fcfa4a

Please sign in to comment.