]> iEval git - gruntmaster-daemon.git/blame_incremental - lib/Gruntmaster/Daemon/Runner/Interactive.pm
Add COPYING
[gruntmaster-daemon.git] / lib / Gruntmaster / Daemon / Runner / Interactive.pm
... / ...
CommitLineData
1package Gruntmaster::Daemon::Runner::Interactive;
2
3use 5.014000;
4use strict;
5use warnings;
6
7use File::Slurp qw/slurp/;
8use Gruntmaster::Daemon::Constants qw/WA/;
9use Log::Log4perl qw/get_logger/;
10use POSIX qw/mkfifo/;
11use Try::Tiny;
12
13our $VERSION = '5999-TRIAL';
14
15##################################################
16
17sub run{
18 my ($test, $meta) = @_;
19 get_logger->trace("Running on test $test...");
20
21 mkfifo 'fifo1', 0600 or die $! unless -e 'fifo1';
22 mkfifo 'fifo2', 0600 or die $! unless -e 'fifo2';
23
24 my $ret = fork // get_logger->logdie("Fork failed: $!");
25 if ($ret) {
26 $meta->{files}{prog}{run}->($meta->{files}{prog}{name}, fds => [qw/0 fifo1 1 >fifo2/], map {defined $meta->{$_} ? ($_ => $meta->{$_}) : () } qw/timeout mlimit/);
27 waitpid $ret, 0;
28 die [WA, "Wrong Answer"] if $?;
29 } else {
30 try {
31 $meta->{files}{int}{run}->($meta->{files}{int}{name}, fds => [qw/1 >fifo1 0 fifo2 4 >result/]);
32 } catch {
33 exit 1;
34 };
35 exit
36 }
37
38 scalar slurp 'result'
39}
40
411
This page took 0.015838 seconds and 4 git commands to generate.