Update documentation and version
[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
bc372959
MG
13our $VERSION = '5999-TRIAL';
14
5c5cd38a
MG
15##################################################
16
17sub run{
18 my ($test, $meta) = @_;
19 get_logger->trace("Running on test $test...");
5c5cd38a
MG
20
21 mkfifo 'fifo1', 0600 or die $! unless -e 'fifo1';
22 mkfifo 'fifo2', 0600 or die $! unless -e 'fifo2';
2d67a3e6
MG
23
24 my $ret = fork // get_logger->logdie("Fork failed: $!");
5c5cd38a
MG
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/);
2d67a3e6 27 waitpid $ret, 0;
5c5cd38a
MG
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
bc372959 411
This page took 0.012924 seconds and 4 git commands to generate.