diff options
author | doy <doy@tozt.net> | 2009-02-03 21:07:59 -0500 |
---|---|---|
committer | doy <doy@tozt.net> | 2009-02-03 21:07:59 -0500 |
commit | 16293185abdce3ab230199208440769c8abb59b6 (patch) | |
tree | db75a29b846e83f01d3eaabe78d4d13f08e14d02 | |
parent | db35dd17e7c9268ca5300b3a475cf93f1f70f04c (diff) | |
download | io-pty-easy-16293185abdce3ab230199208440769c8abb59b6.tar.gz io-pty-easy-16293185abdce3ab230199208440769c8abb59b6.zip |
use waitpid rather than wait, and don't mess with SIGCHLD at all
-rw-r--r-- | lib/IO/Pty/Easy.pm | 10 |
1 files 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; } |