From c020b922b2b04878b04b8d7e84079087f1dc2abc Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Mon, 21 Apr 2014 21:04:58 +0300 Subject: [PATCH] Avoid zombies on TLE in interactive problems --- lib/Gruntmaster/Daemon/Runner/Interactive.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Gruntmaster/Daemon/Runner/Interactive.pm b/lib/Gruntmaster/Daemon/Runner/Interactive.pm index 115e7a1..5a98675 100644 --- a/lib/Gruntmaster/Daemon/Runner/Interactive.pm +++ b/lib/Gruntmaster/Daemon/Runner/Interactive.pm @@ -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 { -- 2.39.2