AnyEvent-Subprocess

 view release on metacpan or  search on metacpan

lib/AnyEvent/Subprocess/DefaultDelegates.pm  view on Meta::CPAN

this delegate will steal all input.  Captured output is returned in
via a delegate in the "done class".)

=head2 MonitorHandle

Calls a list of coderefs whenever a line is read from a handle.

=head2 PrintError

Delegate that calls a callback in the child to print the exception (if
any) the child throws.

Use WithResult if you want to actually get the exception in the parent.

=head1 Timeout

Kill the subprocess with a signal C<kill_with> after C<timeout>
seconds elapse.  See L<AnyEvent::Subprocess::Job::Delegate::Timeout>.

=head1 SEE ALSO

lib/AnyEvent/Subprocess/Easy.pm  view on Meta::CPAN

directly.

=head1 EXPORTS

We use L<Sub::Exporter|Sub::Exporter> here, so you can customize the
exports as appropriate.

=head2 qx_nonblock( $cmdline | @cmdline )

C<qx_nonblock> works like qx, except that it returns a condvar that
you C<recv> on to get the captured stdout.  The C<recv> will throw an
exception if the process you run doesn't exit cleanly.

You can pass in one string for the shell to interpret (like C<exec>),
or you can pass in a list of arguments (passed directly to C<exec>).
You can also pass in a coderef if you like; it will be called with an
undefined number of arguments in the child process (and should C<exit 0>
if it is successful).

=head1 BUGS

t/easy-qx.t  view on Meta::CPAN

    my $result = $cv->recv;
    diag $result;
    ok length $result > 5, 'got some result back';
}

{
    diag "The 'failed' message you are about to see is good.";
    # if you have a command with this name on your machine...
    my $cv = qx_nonblock('I CAN HAZ', 'CHEZBURGER?');

    throws_ok {
        my $result = $cv->recv;
    } qr/: 255/, 'non-existent command errored';

}



( run in 0.275 second using v1.01-cache-2.11-cpan-496ff517765 )