Skip to content

Instantly share code, notes, and snippets.

/sp.diff Secret

Created February 17, 2017 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/35ea6d9b1fb709fea7dcca8fd349168d to your computer and use it in GitHub Desktop.
Save anonymous/35ea6d9b1fb709fea7dcca8fd349168d to your computer and use it in GitHub Desktop.
diff --git a/lib/Mojo/IOLoop/Subprocess.pm b/lib/Mojo/IOLoop/Subprocess.pm
index 0093df73b..f61fde9c0 100644
--- a/lib/Mojo/IOLoop/Subprocess.pm
+++ b/lib/Mojo/IOLoop/Subprocess.pm
@@ -12,6 +12,8 @@ has deserialize => sub { \&Storable::thaw };
has ioloop => sub { Mojo::IOLoop->singleton };
has serialize => sub { \&Storable::freeze };
+sub DESTROY { kill 'KILL', $_[0]{pid} if $_[0]{pid} }
+
sub pid { shift->{pid} }
sub run {
@@ -45,6 +47,7 @@ sub run {
waitpid $pid, 0;
my $results = eval { $self->deserialize->($buffer) } || [];
$self->$parent(shift(@$results) // $@, @$results);
+ delete $self->{pid};
}
);
return $self;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment