From 16293185abdce3ab230199208440769c8abb59b6 Mon Sep 17 00:00:00 2001 From: doy Date: Tue, 3 Feb 2009 21:07:59 -0500 Subject: use waitpid rather than wait, and don't mess with SIGCHLD at all --- lib/IO/Pty/Easy.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/IO/Pty/Easy.pm b/lib/IO/Pty/Easy.pm index b41258c..5f6451d 100644 --- a/lib/IO/Pty/Easy.pm +++ b/lib/IO/Pty/Easy.pm @@ -129,7 +129,6 @@ sub spawn { # if the exec fails, signal the parent by sending the errno across the pipe # if the exec succeeds, perl will close the pipe, and the sysread will # return due to EOF - $SIG{CHLD} = 'IGNORE'; $self->{pid} = fork; unless ($self->{pid}) { close $readp; @@ -255,6 +254,10 @@ sub is_active { return 0 unless defined $self->{pid}; my $active = kill 0 => $self->{pid}; + if ($active) { + my $pid = waitpid($self->{pid}, POSIX::WNOHANG); + $active = 0 if $pid == $self->{pid}; + } if (!$active) { $SIG{WINCH} = 'DEFAULT' if $self->{handle_pty_size}; delete $self->{pid}; @@ -281,10 +284,7 @@ sub kill { $sig = "TERM" unless defined $sig; my $kills = kill $sig => $self->{pid} if $self->is_active; - if (!$non_blocking) { - wait; - $self->_wait_for_inactive unless $non_blocking; - } + $self->_wait_for_inactive unless $non_blocking; return $kills; } -- cgit v1.2.3-54-g00ecf