api: write stdin to child process

This commit is contained in:
Thomas Hobson 2021-02-23 19:52:49 +13:00
parent 2505b89fcf
commit 9d32012bbc
No known key found for this signature in database
GPG Key ID: 9F1FD9D87950DB6F
1 changed files with 4 additions and 1 deletions

View File

@ -92,13 +92,16 @@ class Job {
gid: this.gid,
detached: true //dont kill the main process when we kill the group
});
proc.stdin.write(this.stdin);
proc.stdin.end();
const kill_timeout = setTimeout(_ => proc.kill('SIGKILL'), timeout);
proc.stderr.on('data', d=>{if(stderr.length>config.output_max_size) proc.kill('SIGKILL'); else stderr += d;});
proc.stdout.on('data', d=>{if(stdout.length>config.output_max_size) proc.kill('SIGKILL'); else stdout += d;});
function exit_cleanup(){
clearTimeout(kill_timeout);
proc.stderr.destroy();