is MojoX::Run really asynchronous
In looking at the SYNOPSIS example for
MojoX::Run
# create async executor SINGLETON object
my $mojox_run = MojoX::Run->singleton();
# simple usage
my $pid = $mojox_run->spawn(
cmd => "ping -W 2 -c 5 host.example.org",
exit_cb => sub {
my ($pid, $res) = @_;
print "Ping finished with exit status $res->{exit_val}
+.\n";
print "\tSTDOUT:\n$res->{stdout}\n";
print "\tSTDERR:\n$res->{stderr}\n";
}
);
# check for injuries
unless ($pid) {
print "Command startup failed: ", $mojox_run->error(), "\n";
}
I'm wondering what is asynchronous about its usage. The reason that I say this is because of the line
unless ($pid) which to me implies that line does not execute until the exit callback fires - there is no other way for
$pid to be bound until then
synchronous shell usage
I like the API for MojoX::Run quite a bit. It makes the calling of shell commands succinct, handling the capture of STDERR and STDOUT, etc. Is there a similar tool on CPAN for synchronous shell usage?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.