Skip to content

Commit ba6d98f

Browse files
committed
add timeout option to unix systems
1 parent 45ab203 commit ba6d98f

File tree

12 files changed

+44
-23
lines changed

12 files changed

+44
-23
lines changed

runners/unix/bash.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
22
cd $1
3-
timeout -s SIGKILL 10 xargs -a args.args -d '\n' bash code.code < stdin.stdin
3+
timeoutInSec=`cat timeout.timeout`
4+
timeout -s SIGKILL $timeoutInSec xargs -a args.args -d '\n' bash code.code < stdin.stdin

runners/unix/cpp.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/sh
22
cd $1
3+
timeoutInSec=`cat timeout.timeout`
34
cp code.code code.c
4-
timeout -s SIGKILL 10 g++ code.c -o a.out
5+
timeout -s SIGKILL 5 g++ code.c -o a.out
56
chmod +x a.out
6-
timeout -s SIGKILL 10 xargs -a args.args -d '\n' ./a.out < stdin.stdin
7+
timeout -s SIGKILL $timeoutInSec xargs -a args.args -d '\n' ./a.out < stdin.stdin

runners/unix/gcc.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/sh
22
cd $1
3+
timeoutInSec=`cat timeout.timeout`
34
cp code.code code.c
4-
timeout -s SIGKILL 10 gcc code.c -o a.out
5+
timeout -s SIGKILL 5 gcc code.c -o a.out
56
chmod +x a.out
6-
timeout -s SIGKILL 10 xargs -a args.args -d '\n' ./a.out < stdin.stdin
7+
timeout -s SIGKILL $timeoutInSec xargs -a args.args -d '\n' ./a.out < stdin.stdin

runners/unix/go.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
22
cd $1
3+
timeoutInSec=`cat timeout.timeout`
34
cp code.code code.go
4-
timeout -s SIGKILL 10 xargs -a args.args -d '\n' go run code.go < stdin.stdin
5+
timeout -s SIGKILL $timeoutInSec xargs -a args.args -d '\n' go run code.go < stdin.stdin

runners/unix/java.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
22
cd $1
3+
timeoutInSec=`cat timeout.timeout`
34
cp code.code interim.java
4-
timeout -s SIGKILL 10 xargs -a args.args -d '\n' java interim.java < stdin.stdin
5+
timeout -s SIGKILL $timeoutInSec xargs -a args.args -d '\n' java interim.java < stdin.stdin

runners/unix/js.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
22
cd $1
3-
timeout -s SIGKILL 10 xargs -a args.args -d '\n' node code.code < stdin.stdin
3+
timeoutInSec=`cat timeout.timeout`
4+
timeout -s SIGKILL $timeoutInSec xargs -a args.args -d '\n' node code.code < stdin.stdin

runners/unix/python2.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
22
cd $1
3-
timeout -s SIGKILL 10 xargs -a args.args -d '\n' python2 code.code < stdin.stdin
3+
timeoutInSec=`cat timeout.timeout`
4+
timeout -s SIGKILL $timeoutInSec xargs -a args.args -d '\n' python2 code.code < stdin.stdin

runners/unix/python3.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
22
cd $1
3-
timeout -s SIGKILL 10 xargs -a args.args -d '\n' python3 code.code < stdin.stdin
3+
timeoutInSec=`cat timeout.timeout`
4+
timeout -s SIGKILL $timeoutInSec xargs -a args.args -d '\n' python3 code.code < stdin.stdin

runners/unix/ruby.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
22
cd $1
3-
timeout -s SIGKILL 10 xargs -a args.args -d '\n' ruby code.code < stdin.stdin
3+
timeoutInSec=`cat timeout.timeout`
4+
timeout -s SIGKILL $timeoutInSec xargs -a args.args -d '\n' ruby code.code < stdin.stdin

src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ export enum Environment {
2121
export interface IExecuteOptions {
2222
timeout?: number;
2323
}
24+
25+
export const defaultExecutionTimeout = 5;

0 commit comments

Comments
 (0)