mirror of
https://github.com/engineer-man/piston.git
synced 2025-04-22 04:56:30 +02:00
Add stdin
This commit is contained in:
parent
8fd831982e
commit
c537cab2da
30 changed files with 42 additions and 32 deletions
|
@ -14,13 +14,15 @@ epoch=$(date +%s%N)
|
|||
basepath="/var/lib/lxc/piston/rootfs"
|
||||
filepath="/tmp/$epoch/code.code"
|
||||
argpath="/tmp/$epoch/args.args"
|
||||
stdinpath="/tmp/$epoch/stdin.stdin"
|
||||
arg=$(basename $argpath)
|
||||
|
||||
# write arg file
|
||||
mkdir -p $basepath/tmp/$epoch
|
||||
chmod 777 $basepath/tmp/$epoch
|
||||
cat $2 > $basepath$filepath
|
||||
echo "${@:3}" > $basepath$argpath
|
||||
cat $3 > $basepath$argpath
|
||||
echo "${@:4}" > $basepath$argpath
|
||||
|
||||
# process incrementor
|
||||
exec 200>$dir/lockfile
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
cd /tmp/$2
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 bash code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 bash code.code < stdin.stdin"
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
cd /tmp/$2
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 brainfuck code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 brainfuck code.code < stdin.stdin"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
runuser runner$1 -c "\
|
||||
cd /tmp/$2 ; \
|
||||
gcc -std=c11 -o binary -x c code.code ; \
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary"
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
runuser runner$1 -c "\
|
||||
cd /tmp/$2 ; \
|
||||
g++ -std=c++17 -o binary -x c++ code.code ; \
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary"
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
runuser runner$1 -c "\
|
||||
cd /tmp/$2 ; \
|
||||
mcs $(echo code.code | sed 's/\///') -nowarn:0219 -out:binary ; \
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 mono binary"
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 mono binary < stdin.stdin"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
cd /tmp/$2
|
||||
|
||||
if [[ -z $(grep '[^[:space:]]' args.args) ]]; then
|
||||
runuser runner$1 -c "cd /tmp/$2 ; timeout -s KILL 3 deno run code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; timeout -s KILL 3 deno run code.code < stdin.stdin"
|
||||
else
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 deno run code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 deno run code.code < stdin.stdin"
|
||||
fi
|
||||
|
|
|
@ -3,5 +3,5 @@ cd /tmp/$2
|
|||
if [[ -z $(grep '[^[:space:]]' args.args) ]]; then
|
||||
runuser runner$1 -c "cd /tmp/$2 ; timeout -s KILL 3 elixir code.code"
|
||||
else
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args ; xargs -d '\n' timeout -s KILL 3 elixir code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args ; xargs -d '\n' timeout -s KILL 3 elixir code.code < stdin.stdin"
|
||||
fi
|
||||
|
|
|
@ -3,5 +3,5 @@ cd /tmp/$2
|
|||
if [[ -z $(grep '[^[:space:]]' args.args) ]]; then
|
||||
runuser runner$1 -c "cd /tmp/$2 ; timeout -s KILL 3 emacs -Q --script code.code"
|
||||
else
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 emacs -Q --script code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 emacs -Q --script code.code < stdin.stdin"
|
||||
fi
|
||||
|
|
|
@ -3,4 +3,4 @@ cp code.code interim.go
|
|||
file="interim.go"
|
||||
go build $file
|
||||
file=${file%%.*}
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 ./$file"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 ./$file < stdin.stdin"
|
||||
|
|
|
@ -4,4 +4,4 @@ mv code.code code.hs
|
|||
runuser runner$1 -c "\
|
||||
cd /tmp/$2 ; \
|
||||
ghc -dynamic -o binary code.hs > /dev/null 2>&1 ; \
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary"
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin"
|
||||
|
|
|
@ -6,4 +6,4 @@ mv interim.java $name.java
|
|||
runuser runner$1 -c "\
|
||||
cd /tmp/$2 ; \
|
||||
javac $name.java ; \
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 java $name"
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 java $name < stdin.stdin"
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
cd /tmp/$2
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 jelly fu code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 jelly fu code.code < stdin.stdin"
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
cd /tmp/$2
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 julia code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 julia code.code < stdin.stdin"
|
||||
|
|
|
@ -3,4 +3,4 @@ cp code.code code.kt
|
|||
runuser runner$1 -c "\
|
||||
cd /tmp/$2 ; \
|
||||
kotlinc code.kt -include-runtime -d code.jar ; \
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 java -jar code.jar"
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 java -jar code.jar < stdin.stdin"
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
cd /tmp/$2
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 lua code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 lua code.code < stdin.stdin"
|
||||
|
|
|
@ -2,4 +2,4 @@ runuser runner$1 -c "\
|
|||
cd /tmp/$2 ; \
|
||||
nasm -f elf32 -o binary.o code.code ; \
|
||||
ld -m elf_i386 binary.o -o binary ; \
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary"
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin"
|
||||
|
|
|
@ -2,4 +2,4 @@ runuser runner$1 -c "\
|
|||
cd /tmp/$2 ; \
|
||||
nasm -f elf64 -o binary.o code.code ; \
|
||||
ld -m elf_x86_64 binary.o -o binary ; \
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary"
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
cd /tmp/$2
|
||||
|
||||
if [[ -z $(grep '[^[:space:]]' args.args) ]]; then
|
||||
runuser runner$1 -c "cd /tmp/$2 ; timeout -s KILL 3 node code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; timeout -s KILL 3 node code.code < stdin.stdin"
|
||||
else
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 node code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 node code.code < stdin.stdin"
|
||||
fi
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
cd /tmp/$2
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 perl code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 perl code.code < stdin.stdin"
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
cd /tmp/$2
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 php code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 php code.code < stdin.stdin"
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
cd /tmp/$2
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 python code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 python code.code < stdin.stdin"
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
cd /tmp/$2
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 python3.8 code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 python3.8 code.code < stdin.stdin"
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
cd /tmp/$2
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 ruby code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 ruby code.code < stdin.stdin"
|
||||
|
|
|
@ -2,4 +2,4 @@ cd /tmp/$2
|
|||
rustc -o binary code.code
|
||||
runuser runner$1 -c "\
|
||||
cd /tmp/$2 ; \
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary"
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 ./binary < stdin.stdin"
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
cd /tmp/$2
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 swift code.code"
|
||||
runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 swift code.code < stdin.stdin"
|
||||
|
|
|
@ -4,4 +4,4 @@ runuser runner$1 -c "\
|
|||
tsc interim.ts ; \
|
||||
rm -f interim.ts ; \
|
||||
mv interim.js code.code ; \
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 node code.code"
|
||||
cat args.args | xargs -d '\n' timeout -s KILL 3 node code.code < stdin.stdin"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue