[sandbox] Terminate after 30 seconds
This commit is contained in:
parent
83b5d75ed1
commit
97b8f6028a
@ -33,8 +33,22 @@ export async function runJava(
|
|||||||
child.stdin.write(input);
|
child.stdin.write(input);
|
||||||
child.stdin.end();
|
child.stdin.end();
|
||||||
|
|
||||||
|
let resolved = false;
|
||||||
|
|
||||||
child.on('close', () => {
|
child.on('close', () => {
|
||||||
resolve(outputBuffer);
|
if (!resolved) {
|
||||||
|
resolved = true;
|
||||||
|
resolve(outputBuffer);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!resolved) {
|
||||||
|
console.log('30 seconds reached, killing process');
|
||||||
|
resolved = true;
|
||||||
|
child.kill('SIGKILL');
|
||||||
|
resolve(outputBuffer + '\n[Timeout after 30 seconds]');
|
||||||
|
}
|
||||||
|
}, 30000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user