AnyEvent-Subprocess
view release on metacpan or search on metacpan
lib/AnyEvent/Subprocess/Running.pm view on Meta::CPAN
for my $d ($self->_delegates){
my %events = map { $_ => $joiner->event_sender_for($_) } $d->build_events;
$d->event_senders(\%events);
}
return $joiner;
},
);
sub _completion_hook {
my ($self, %args) = @_;
my $status = $args{status};
my $done = AnyEvent::Subprocess::Done->new(
delegates => [$self->_invoke_delegates('build_done_delegates')],
exit_status => $status,
);
$args{done} = $done;
$args{run} = $self;
$self->_invoke_delegates('completion_hook', \%args);
$self->on_completion->($done);
}
sub kill {
my $self = shift;
my $signal = shift || 9;
kill $signal, $self->child_pid; # BAI
}
sub BUILD {
my $self = shift;
$self->child_event_joiner; # vivify
}
__PACKAGE__->meta->make_immutable;
1;
=pod
=head1 NAME
AnyEvent::Subprocess::Running - represents a running subprocess
=head1 VERSION
version 1.102912
=head1 SYNOPSIS
We are C<$run> in a sequence like:
my $job = AnyEvent::Subprocess->new ( ... );
my $run = $job->run;
$run->delegate('stdin')->push_write('Hello, my child!');
say "Running child as ", $run->child_pid;
$run->kill(11) if $you_enjoy_that_sort_of_thing;
my $done = $job->delegate('completion_condvar')->recv;
say "Child exited with signal ", $done->exit_signal;
=head1 DESCRIPTION
An instance of this class is returned when you start a subprocess. It
contains the child pid, any delegates that operate on the running
subprocess (handles, captures, etc.), and some control methods.
=head1 METHODS
=head2 child_pid
Returns the pid of the child
=head2 kill($signal)
Kills the child with signal number C<$signal>
=head2 delegate($name)
Returns the delegate named C<$name>
=head1 SEE ALSO
L<AnyEvent::Subprocess>
L<AnyEvent::Subprocess::Role::WithDelegates>
=head1 AUTHOR
Jonathan Rockway <jrockway@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Jonathan Rockway.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
__END__
( run in 0.516 second using v1.01-cache-2.11-cpan-483215c6ad5 )