Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use childprocess.send and process.on("message")? #29

Open
daysv opened this issue May 23, 2024 · 1 comment
Open

How to use childprocess.send and process.on("message")? #29

daysv opened this issue May 23, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@daysv
Copy link

daysv commented May 23, 2024

How to use childprocess.send and process.on("message")?

main

const child = fork('xxx')
child.send("hi")

child

process.on("message', () => {})
@TheSpyder TheSpyder added the enhancement New feature or request label May 24, 2024
@TheSpyder
Copy link
Owner

fork has a binding:

@module("node:child_process") @val
external fork: (string, array<string>) => t = "fork"

But I can't find one for send. Likewise there are a few on bindings, but nothing for on("message").

@send
external onData: (t, @as("data") _, @uncurry (Buffer.t => unit)) => t = "on"
@send
external onDisconnect: (t, @as("disconnect") _, @uncurry unit => unit) => t = "on"
@send
external onError: (t, @as("error") _, @uncurry (Js.Exn.t => unit)) => t = "on"
@send
external onExit: (t, @as("exit") _, @uncurry int => unit) => t = "on"
@send
external onClose: (t, @as("close") _, @uncurry int => unit) => t = "on"

So both need to be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants