AnyEvent-Open3-Simple
view release on metacpan or search on metacpan
There are some traps for the unwary relating to buffers and deadlocks,
IPC::Open3 is recommended reading.
If you register a call back for on_exit, but not on_error then use a
condition variable to wait for the process to complete as in this:
my $cv = AnyEvent->condvar;
my $ipc = AnyEvent::Open3::Simple->new(
on_exit => sub { $cv->send },
);
$ipc->run('command_not_found');
$cv->recv;
You might be waiting forever if there is an error starting the process
(if for example you give it a bad command). To handle this situation
you might use croak on the condition variable in the event of error:
my $cv = AnyEvent->condvar;
my $ipc = AnyEvent::Open3::Simple->new(
on_exit => sub { $cv->send },
on_error => sub {
my $error = shift;
$cv->croak($error);
},
);
$ipc->run('command_not_found');
$cv->recv;
This will cause the recv to die, printing a useful diagnostic if the
exception isn't caught somewhere else.
SEE ALSO
AnyEvent::Open3::Simple::Process
Represents a process being run by this module, typically passed into
lib/AnyEvent/Open3/Simple.pm view on Meta::CPAN
L<IPC::Open3> is recommended reading.
If you register a call back for C<on_exit>, but not C<on_error> then
use a condition variable to wait for the process to complete as in
this:
my $cv = AnyEvent->condvar;
my $ipc = AnyEvent::Open3::Simple->new(
on_exit => sub { $cv->send },
);
$ipc->run('command_not_found');
$cv->recv;
You might be waiting forever if there is an error starting the
process (if for example you give it a bad command). To handle
this situation you might use croak on the condition variable
in the event of error:
my $cv = AnyEvent->condvar;
my $ipc = AnyEvent::Open3::Simple->new(
on_exit => sub { $cv->send },
on_error => sub {
my $error = shift;
$cv->croak($error);
},
);
$ipc->run('command_not_found');
$cv->recv;
This will cause the C<recv> to die, printing a useful diagnostic
if the exception isn't caught somewhere else.
=head1 SEE ALSO
=over 4
=item L<AnyEvent::Open3::Simple::Process>
( run in 1.178 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )