From 5a91a065b882215dde209baf626247e54c21a392 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Wed, 13 Dec 2023 15:44:16 +0530 Subject: fix: implement child_process IPC (#21490) This PR implements the Node child_process IPC functionality in Deno on Unix systems. For `fd > 2` a duplex unix pipe is set up between the parent and child processes. Currently implements data passing via the channel in the JSON serialization format. --- cli/args/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'cli/args') diff --git a/cli/args/mod.rs b/cli/args/mod.rs index c65745e29..17711371a 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -939,6 +939,17 @@ impl CliOptions { .map(Some) } + pub fn node_ipc_fd(&self) -> Option { + let maybe_node_channel_fd = std::env::var("DENO_CHANNEL_FD").ok(); + if let Some(node_channel_fd) = maybe_node_channel_fd { + // Remove so that child processes don't inherit this environment variable. + std::env::remove_var("DENO_CHANNEL_FD"); + node_channel_fd.parse::().ok() + } else { + None + } + } + pub fn resolve_main_module(&self) -> Result { match &self.flags.subcommand { DenoSubcommand::Bundle(bundle_flags) => { -- cgit v1.2.3