fix(agent): bound CLI subprocess execution
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { closeSync } from "node:fs";
|
||||
|
||||
const command = process.argv[3];
|
||||
const value = process.argv[4] ?? "";
|
||||
|
||||
if (command === "stdout") {
|
||||
process.stdout.write(value);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (command === "stderr") {
|
||||
process.stderr.write(value);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (command === "term") {
|
||||
process.on("SIGTERM", () => {
|
||||
setTimeout(() => process.exit(0), 30);
|
||||
});
|
||||
setInterval(() => undefined, 1000);
|
||||
}
|
||||
|
||||
if (command === "ignore-term") {
|
||||
process.on("SIGTERM", () => undefined);
|
||||
setInterval(() => undefined, 1000);
|
||||
}
|
||||
|
||||
if (command === "closed-stdin") {
|
||||
closeSync(0);
|
||||
setInterval(() => undefined, 1000);
|
||||
}
|
||||
Reference in New Issue
Block a user