AnyEvent-Subprocess
view release on metacpan or search on metacpan
lib/AnyEvent/Subprocess/Handle.pm view on Meta::CPAN
return if $self->{finalized}++;
$self->_drain_rbuf;
$self->on_finalize->();
}
sub name {
my $self = shift;
return $self->{_name} || "<fd ". fileno($self->fh). ">";
}
sub do_not_want {
my $self = shift;
close $self->fh if $self->fh; # sometimes people close too soon
$self->destroy;
}
# not push_close, since I am not sure what the semantics of that would
# be. use "on_drain( close_fh )" to close after your last write (or
# push_shutdown).
sub close_fh {
my $self = shift;
lib/AnyEvent/Subprocess/Job/Delegate/Handle.pm view on Meta::CPAN
sub parent_finalize_hook {
my $self = shift;
close $self->pipes->[1];
}
sub child_setup_hook {
my $self = shift;
my $name = $self->handle->name;
$self->handle->do_not_want; # DO NOT WANT (in child)
# reopen fake fds to the "real" ones
my $ch = $self->pipes->[1];
if ($self->has_replace) {
my $replacement = ref $self->replace ?
fileno($self->replace) :
$self->replace;
lib/AnyEvent/Subprocess/Job/Delegate/Pty.pm view on Meta::CPAN
sub parent_finalize_hook {
my $self = shift;
$self->pty->close_slave;
}
sub child_setup_hook {
my $self = shift;
$self->pty->make_slave_controlling_terminal;
$self->handle->do_not_want;
AnyEvent::Util::fh_nonblocking $self->slave_pty, 0;
for my $fh ($self->redirect_handles){
dup2( fileno($self->slave_pty), fileno($fh) )
or confess "Can't dup2 $fh to slave pty: $!";
}
}
sub build_code_args {}
t/death-by-stdin.t view on Meta::CPAN
);
$run->delegate('stdout')->handle->push_read(
line => sub { my ($h, $d) = @_; $got_exit->send($d) },
);
$run->delegate('stdin')->handle->push_write("This is line 1\n");
my $line = $got_line->recv;
is $line, "Got line: This is line 1", 'echoed line OK';
$run->delegate('stdin')->handle->do_not_want;
my $exit = $got_exit->recv;
is $exit, "Exiting cleanly", 'got message about exiting cleanly';
my $done = $condvar->recv;
is $done->exit_value, 0, 'exited with status 0';
( run in 0.382 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )