Initial commit
[gruntmaster-daemon.git] / lib / Gruntmaster / Daemon / Runner / Interactive.pm
CommitLineData
5c5cd38a
MG
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
13##################################################
14
15sub run{
16 my ($test, $meta) = @_;
17 get_logger->trace("Running on test $test...");
18 my $ret = fork // get_logger->logdie("Fork failed: $!");
19
20 mkfifo 'fifo1', 0600 or die $! unless -e 'fifo1';
21 mkfifo 'fifo2', 0600 or die $! unless -e 'fifo2';
22 if ($ret) {
23 $meta->{files}{prog}{run}->($meta->{files}{prog}{name}, fds => [qw/0 fifo1 1 >fifo2/], map {defined $meta->{$_} ? ($_ => $meta->{$_}) : () } qw/timeout mlimit/);
24 wait;
25 die [WA, "Wrong Answer"] if $?;
26 } else {
27 try {
28 $meta->{files}{int}{run}->($meta->{files}{int}{name}, fds => [qw/1 >fifo1 0 fifo2 4 >result/]);
29 } catch {
30 exit 1;
31 };
32 exit
33 }
34
35 scalar slurp 'result'
36}
37
381;
39__END__
This page took 0.01307 seconds and 4 git commands to generate.