Skip to content

Commit

Permalink
Close unused pipes (#3590)
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Zeithaml <[email protected]>
  • Loading branch information
Martin-Zeithaml authored Oct 11, 2023
1 parent 4c8809b commit 8f981ac
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions bin/libs/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ export function execOutSync(command: string, ...args: string[]): ExecReturn {
return { rc: -1 };
}
const rc = os.exec([command, ...args], { block: true, usePath: true, stdout: pipeArray[1]});
os.close(pipeArray[1]);

let out = readStreamFully(pipeArray[0]);
os.close(pipeArray[0]);
os.close(pipeArray[1]);

return {
rc, out
Expand All @@ -94,11 +94,11 @@ export function execErrSync(command: string, ...args: string[]): ExecReturn {
if (!pipeArray){
return { rc: -1 };
}
const rc = os.exec([command, ...args], { block: true, usePath: true, stderr: pipeArray[1]});

const rc = os.exec([command, ...args], { block: true, usePath: true, stderr: pipeArray[1]});
os.close(pipeArray[1]);

let err = readStreamFully(pipeArray[0]);
os.close(pipeArray[0]);
os.close(pipeArray[1]);

return {
rc, err
Expand All @@ -117,16 +117,17 @@ export function execOutErrSync(command: string, ...args: string[]): ExecReturn {
return { rc: -1 };
}
const rc = os.exec([command, ...args], { block: true, usePath: true, stdout: pipeArray[1], stderr: errArray[1]});
os.close(pipeArray[1]);
os.close(errArray[1]);

let out = readStreamFully(pipeArray[0]);
os.close(pipeArray[0]);
os.close(pipeArray[1]);


let err = readStreamFully(errArray[0]);
os.close(errArray[0]);
os.close(errArray[1]);

return {
rc, err
rc, out, err
};
}

Expand Down

0 comments on commit 8f981ac

Please sign in to comment.