diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-12-13 15:44:16 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-13 11:14:16 +0100 |
commit | 5a91a065b882215dde209baf626247e54c21a392 (patch) | |
tree | 192cb8b3b0a4037453b5fd5b2a60e4d52d4543a8 /ext/node/polyfills/child_process.ts | |
parent | bbf8f69cb979be0f36c38ae52b1588e648b3252e (diff) |
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.
Diffstat (limited to 'ext/node/polyfills/child_process.ts')
-rw-r--r-- | ext/node/polyfills/child_process.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/ext/node/polyfills/child_process.ts b/ext/node/polyfills/child_process.ts index 94a108447..c7d007f46 100644 --- a/ext/node/polyfills/child_process.ts +++ b/ext/node/polyfills/child_process.ts @@ -10,6 +10,7 @@ import { ChildProcess, ChildProcessOptions, normalizeSpawnArguments, + setupChannel, type SpawnOptions, spawnSync as _spawnSync, type SpawnSyncOptions, @@ -821,6 +822,14 @@ export function execFileSync( return ret.stdout as string | Buffer; } +function setupChildProcessIpcChannel(fd: number) { + if (typeof fd != "number" || fd < 0) return; + setupChannel(process, fd); +} + +globalThis.__bootstrap.internals.__setupChildProcessIpcChannel = + setupChildProcessIpcChannel; + export default { fork, spawn, |