Skip to content

Commit

Permalink
jberger says we want POSIX::_exit(0)
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 27, 2016
1 parent e43afba commit 036f311
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@

7.04 2016-08-27
7.04 2016-08-28
- Added EXPERIMENTAL support for performing computationally expensive
operations in subprocesses, without blocking the event loop. (jberger, sri)
- Added EXPERIMENTAL module Mojo::IOLoop::Subprocess. (jberger, sri)
Expand Down
4 changes: 3 additions & 1 deletion lib/Mojo/IOLoop/Subprocess.pm
Expand Up @@ -5,6 +5,7 @@ use Carp 'croak';
use Config;
use Mojo::IOLoop;
use Mojo::IOLoop::Stream;
use POSIX ();
use Storable;

has deserialize => sub { \&Storable::thaw };
Expand All @@ -21,14 +22,15 @@ sub run {

# Pipe for subprocess communication
pipe(my $reader, my $writer) or croak "Can't create pipe: $!";
$writer->autoflush(1);

# Child
croak "Can't fork: $!" unless defined($self->{pid} = fork);
unless ($self->{pid}) {
$self->ioloop->reset;
my $results = eval { [$self->$first] } || [];
print $writer $self->serialize->([$@, @$results]);
exit 0;
POSIX::_exit(0);
}

# Parent
Expand Down

0 comments on commit 036f311

Please sign in to comment.