13 lines
806 B
JavaScript
13 lines
806 B
JavaScript
// Filbert, row 39 r2: what ChildProcess.send() does on a child that has exited, as
|
|
// startHost's notifier-failure path would call broker.send({op: "close"}) after the broker died.
|
|
import { fork } from "node:child_process";
|
|
import { once } from "node:events";
|
|
import { fileURLToPath } from "node:url";
|
|
if (process.argv[2] === "child") process.exit(0);
|
|
const c = fork(fileURLToPath(import.meta.url), ["child"], { stdio: ["ignore", "inherit", "inherit", "ipc"] });
|
|
await once(c, "exit");
|
|
console.log("connected", c.connected, "exitCode", c.exitCode);
|
|
try { c.send({ op: "close" }); console.log("send returned without throwing"); } catch (e) { console.log("send threw", e.code); }
|
|
process.on("exit", (code) => console.log("process exit code", code));
|
|
process.exitCode = 3; // what the CLI sets for a refusal
|