-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
30 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env node | ||
const { spawn } = require("child_process"); | ||
const { normalize } = require("path"); | ||
|
||
// 'disconnect' is not needed as it will only be raised, when either the child process or this process calss disconnect explicitly. | ||
// We are abel to ensure, that this will never happen, as we do not need communication with the spawned subprocess | ||
const terminationSignals = ["close", "exit"]; | ||
|
||
function startSubprocess() { | ||
return new Promise((res, rej) => { | ||
const [command, ...args] = process.argv.slice(2); | ||
const proc = spawn(normalize(command), args, { | ||
// use parents stdio | ||
stdio: "inherit", | ||
shell: | ||
process.platform === "win32" || | ||
/^(msys|cygwin)$/.test(process.env.OSTYPE), | ||
}); | ||
terminationSignals.forEach((event) => proc.on(event, res)); | ||
proc.on("error", rej); | ||
}); | ||
} | ||
|
||
async function loop() { | ||
let code = 64; | ||
while (code === 64) code = await startSubprocess(); | ||
} | ||
|
||
loop(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters