summaryrefslogtreecommitdiff
path: root/tests/specs/node/stdio_ipc/main.mjs
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-06-07 22:51:32 +0530
committerGitHub <noreply@github.com>2024-06-07 22:51:32 +0530
commit3735a1a54225a058914f4356c2d271bb12fab6a7 (patch)
treeb7c21736a0f2daa1ac659d8a82e34f572c7c7ae9 /tests/specs/node/stdio_ipc/main.mjs
parented20102713dd3269629b8e329f62d081be506430 (diff)
fix(ext/node): support stdin child_process IPC & fd stdout/stderr (#24106)
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
Diffstat (limited to 'tests/specs/node/stdio_ipc/main.mjs')
-rw-r--r--tests/specs/node/stdio_ipc/main.mjs16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/specs/node/stdio_ipc/main.mjs b/tests/specs/node/stdio_ipc/main.mjs
new file mode 100644
index 000000000..4a1a8ddbd
--- /dev/null
+++ b/tests/specs/node/stdio_ipc/main.mjs
@@ -0,0 +1,16 @@
+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);
+ });
+}