mirror of
https://github.com/denoland/deno.git
synced 2024-12-30 02:59:11 -05:00
3735a1a542
Add supports for "ipc" and fd options in child_process spawn API. Internal changes: Adds a hidden rid and "ipc_for_internal_use" option to Deno.Command. Used by `node:child_process` Example: ```js const out = fs.openSync("./logfile.txt", 'a') const proc = spawn(process.execPath, ["./main.mjs", "child"], { stdio: ["ipc", out, "inherit"] }); ``` Ref #16753
16 lines
378 B
JavaScript
16 lines
378 B
JavaScript
import { spawn } from "node:child_process";
|
|
import process from "node:process";
|
|
|
|
if (process.argv[2] === "child") {
|
|
process.send("hahah");
|
|
} else {
|
|
const proc = spawn(process.execPath, ["./main.mjs", "child"], {
|
|
stdio: ["ipc", "inherit", "inherit"],
|
|
});
|
|
|
|
proc.on("message", function (msg) {
|
|
console.log(`msg: ${msg}`);
|
|
proc.kill();
|
|
Deno.exit(0);
|
|
});
|
|
}
|