Avoid zombies on TLE in interactive problems
authorMarius Gavrilescu <marius@ieval.ro>
Mon, 21 Apr 2014 18:04:58 +0000 (21:04 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Mon, 21 Apr 2014 21:07:38 +0000 (00:07 +0300)
lib/Gruntmaster/Daemon/Runner/Interactive.pm

index 115e7a1..5a98675 100644 (file)
@@ -23,8 +23,13 @@ sub run{
 
        my $ret = fork // get_logger->logdie("Fork failed: $!");
        if ($ret) {
-               $meta->{files}{prog}{run}->($meta->{files}{prog}{name}, fds => [qw/0 fifo1 1 >fifo2/], map {defined $meta->{$_} ? ($_ => $meta->{$_}) : () } qw/timeout mlimit/);
-               waitpid $ret, 0;
+               try {
+                       $meta->{files}{prog}{run}->($meta->{files}{prog}{name}, fds => [qw/0 fifo1 1 >fifo2/], map {defined $meta->{$_} ? ($_ => $meta->{$_}) : () } qw/timeout mlimit/);
+               } catch {
+                       die $_
+               } finally {
+                       waitpid $ret, 0;
+               };
                die [WA, "Wrong Answer"] if $?;
        } else {
                try {
This page took 0.024097 seconds and 4 git commands to generate.