X-Git-Url: http://git.ieval.ro/?p=gruntmaster-daemon.git;a=blobdiff_plain;f=lib%2FGruntmaster%2FDaemon%2FRunner%2FInteractive.pm;h=da51380200c0addf58ae8c9bd2ce94da4dfacc5a;hp=ed9a056f2aac09e5907a35f15a18d4b3c336f98a;hb=614700357f0af54cdba3ac21b7420738bda2f3fe;hpb=fa6276b8ab82354aee7688830c79eada720f78ce diff --git a/lib/Gruntmaster/Daemon/Runner/Interactive.pm b/lib/Gruntmaster/Daemon/Runner/Interactive.pm index ed9a056..da51380 100644 --- a/lib/Gruntmaster/Daemon/Runner/Interactive.pm +++ b/lib/Gruntmaster/Daemon/Runner/Interactive.pm @@ -21,30 +21,27 @@ sub run{ mkfifo 'fifo1', 0600 or die "$!\n" unless -e 'fifo1'; mkfifo 'fifo2', 0600 or die "$!\n" unless -e 'fifo2'; - my $ret = fork // get_logger->logdie("Fork failed: $!"); - if ($ret) { - try { - my @fds = $ENV{GRUNTMASTER_VM} ? qw,0 /dev/ttyS1 1 >/dev/ttyS1, : qw/0 fifo1 1 >fifo2/; - $meta->{files}{prog}{run}->($meta->{files}{prog}{name}, fds => \@fds, map { $_ => $meta->{$_} } qw/timeout mlimit/); - } catch { - die $_ ## no critic (RequireCarping) - } finally { - waitpid $ret, 0; - }; - die [WA, 'Wrong Answer'] if $?; ## no critic (RequireCarping) - } else { - try { - my @fds = $ENV{GRUNTMASTER_VM} ? qw,1 >/dev/ttyS1 0 /dev/ttyS1, : qw/1 >fifo1 0 fifo2/; - $meta->{files}{ver}{run}->($meta->{files}{ver}{name}, fds => [@fds, qw,4 >result,], args => [$test], map { $_ => $meta->{$_} } qw/timeout mlimit/); - } catch { - exit 1; - }; - exit - } + my @fds = $ENV{GRUNTMASTER_VM} ? qw,0 /dev/ttyS1 1 >/dev/ttyS1, : qw/0 fifo1 1 >fifo2/; + $meta->{files}{prog}{run}->($meta->{files}{prog}{name}, nonblocking => 1, fds => \@fds, map { $_ => $meta->{$_} } qw/timeout mlimit/); + + my $fail; + @fds = $ENV{GRUNTMASTER_VM} ? qw,1 >/dev/ttyS1 0 /dev/ttyS1, : qw/1 >fifo1 0 fifo2/; + try { + $meta->{files}{ver}{run}->($meta->{files}{ver}{name}, fds => [@fds, qw,4 >result,], args => [$test], map { $_ => $meta->{$_} } qw/timeout mlimit/); + } catch { + $fail = [WA, 'Wrong Answer']; + }; + + try { + Gruntmaster::Daemon::Format::execlist_finish(prog => !$fail); + } catch { + $fail = $_; + }; unlink 'fifo1'; unlink 'fifo2'; + die $fail if $fail; ## no critic (RequireCarping) scalar slurp 'result' or 'Ok' }