File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 33import { exec } from "child_process" ;
44import { mkdirSync , writeFileSync , readFileSync , chmodSync } from "fs" ;
55import { platform } from "os" ;
6- import { Language } from "./constants" ;
6+ import {
7+ defaultExecutionTimeout ,
8+ IExecuteOptions ,
9+ Language ,
10+ } from "./constants" ;
711
812class LXC {
913 LXC_ROOT_FS : string ;
@@ -77,7 +81,8 @@ class LXC {
7781 input : string ,
7882 language : Language ,
7983 args : string [ ] = [ ] ,
80- stdin : string = ""
84+ stdin : string = "" ,
85+ options : IExecuteOptions = { timeout : defaultExecutionTimeout }
8186 ) {
8287 const id = new Date ( ) . getTime ( ) + "_" + Math . floor ( Math . random ( ) * 10000 ) ;
8388
@@ -86,6 +91,10 @@ class LXC {
8691 writeFileSync ( `${ this . LXC_ROOT_FS } /tmp/${ id } /code.code` , input ) ;
8792 writeFileSync ( `${ this . LXC_ROOT_FS } /tmp/${ id } /args.args` , args . join ( "\n" ) ) ;
8893 writeFileSync ( `${ this . LXC_ROOT_FS } /tmp/${ id } /stdin.stdin` , stdin ) ;
94+ writeFileSync (
95+ `${ this . LXC_ROOT_FS } /tmp/${ id } /timeout.timeout` ,
96+ ( options . timeout || defaultExecutionTimeout ) . toString ( )
97+ ) ;
8998
9099 // Copy .sh file to correct location
91100 const shFile = readFileSync (
You can’t perform that action at this time.
0 commit comments