Copy input to Scaleway in Interactive.pm
[gruntmaster-daemon.git] / gruntmaster-exec
index fd79d8f316c322c9008f14bbe98b402772011c77..97ac555311340538bb1271704b6a63fbf1c3b704 100755 (executable)
@@ -39,7 +39,25 @@ GetOptions(
        "sudo!"        => \$sudo,
 );
 
-my $killuser = $ENV{GRUNTMASTER_KILL_USER};
+sub test_pipe_read {
+       my $data = '';
+       sysread STDIN, $data, 4096 and syswrite STDOUT, "recvd\n" until $data =~ /done/;
+       syswrite STDOUT, 'done';
+}
+
+sub test_pipe_write {
+       my ($rin, $rout);
+       vec($rin, fileno STDIN, 1) = 1;
+       syswrite STDOUT, "data\n" until select $rout = $rin, undef, undef, 0.05;
+       syswrite STDOUT, 'done';
+       my $data = '';
+       sysread STDIN, $data, 4096 until $data =~ /done/;
+}
+
+sub test_pipes {
+       $ARGV[0] =~ /prog/ ? test_pipe_read : test_pipe_write
+}
+
 my @sudo;
 @sudo = (shellwords ($ENV{GRUNTMASTER_SUDO}), '--') if $ENV{GRUNTMASTER_SUDO} && $sudo;
 undef $mlimit if @sudo; # sudo wants a lot of address space
@@ -54,11 +72,7 @@ if ($ret) {
                exit !say ERR, "\nNo response from gruntmaster-exec child";
        }
        local $SIG{ALRM} = sub {
-               if ($killuser) {
-                       system @sudo, 'pkill', '-KILL', '-u', $killuser;
-               } else {
-                       kill KILL => $ret
-               }
+               kill KILL => $ret;
                $tle = 1
        };
        alarm ($timeout || 10);
@@ -88,7 +102,8 @@ if ($ret) {
                        POSIX::close $oldfd or die $!;
                }
        }
-       my $nproc = $killuser ? 15 : 1;
+       test_pipes if grep /tty|fifo/, @fds;
+       my $nproc = 15;
        my $debug = $ENV{TEST_VERBOSE};
        %ENV = (ONLINE_JUDGE => 1, PATH => $ENV{PATH}, HOME => $ENV{HOME});
        setrlimit RLIMIT_AS, $mlimit, $mlimit or die $! if $mlimit;
This page took 0.00977 seconds and 4 git commands to generate.