Advertisement
Guest User

Produces no output when executed via morbo

a guest
Dec 26th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.69 KB | None | 0 0
  1. # Produces no output when executed via morbo
  2. use Mojolicious::Lite;
  3. use Mojo::IOLoop;
  4. use Mojo::IOLoop::ReadWriteFork;
  5.  
  6. my $fork = Mojo::IOLoop::ReadWriteFork->new;
  7. my $cat_result = '';
  8.  
  9. $fork->on(error => sub {
  10.   my($fork, $error) = @_;
  11.   warn $error;
  12. });
  13. $fork->on(close => sub {
  14.   my($fork, $exit_value, $signal) = @_;
  15.   warn "got close event";
  16.   print $cat_result;
  17.   #Mojo::IOLoop->stop;
  18. });
  19. $fork->on(read => sub {
  20.   my($fork, $buffer) = @_; # $buffer = both STDERR and STDOUT
  21.   $cat_result .= $buffer;
  22. });
  23.  
  24. $fork->start(
  25.   program => 'ls',
  26.   program_args => [ '-l', '/tmp' ],
  27.   conduit => 'pty',
  28. );
  29.  
  30. #Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
  31. app->start;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement