summaryrefslogtreecommitdiff
path: root/tests/specs/node/stdio_ipc/main.mjs
blob: 4a1a8ddbda7597a4c43228edc433af3332f40d36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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);
  });
}