X-Git-Url: http://git.ieval.ro/?p=gruntmaster-daemon.git;a=blobdiff_plain;f=lib%2FGruntmaster%2FDaemon%2FRunner%2FInteractive.pm;h=da51380200c0addf58ae8c9bd2ce94da4dfacc5a;hp=af1581e1fa805a89aee6ba8a4a1f41c9ceb14227;hb=614700357f0af54cdba3ac21b7420738bda2f3fe;hpb=34a91d9a841432323980cad110047f18bb7ce7d8 diff --git a/lib/Gruntmaster/Daemon/Runner/Interactive.pm b/lib/Gruntmaster/Daemon/Runner/Interactive.pm index af1581e..da51380 100644 --- a/lib/Gruntmaster/Daemon/Runner/Interactive.pm +++ b/lib/Gruntmaster/Daemon/Runner/Interactive.pm @@ -21,35 +21,27 @@ sub run{ mkfifo 'fifo1', 0600 or die "$!\n" unless -e 'fifo1'; mkfifo 'fifo2', 0600 or die "$!\n" unless -e 'fifo2'; - if ($test == 1 && $ENV{GRUNTMASTER_VM}) { - exec 'cat ver.in' if fork; - exec 'cat prog.in' if fork; - } - - 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' }