Angel Java Lopez schreef op 26-10-14 om 21:16:
I never used that feature, but, why not use the "built-in" IPC channel
given by fork?
http://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options
In addition to having all the methods in a normal ChildProcess instance,
the returned object has a communication channel built-in. See
|child.send(message, [sendHandle])|for details.
Then
http://nodejs.org/api/child_process.html#child_process_child_send_message_sendhandle
with examples, child.send, child.on, at parent side, and process.send,
process.on at child side
I guess there are more info at:
http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options
1. |'ipc'| - Create an IPC channel for passing messages/file
descriptors between parent and child. A ChildProcess may have at
most /one/ IPC stdio file descriptor. Setting this option enables
the ChildProcess.send() method. If the child writes JSON messages to
this file descriptor, then this will trigger
ChildProcess.on('message'). If the child is a Node.js program, then
the presence of an IPC channel will enable process.send() and
process.on('message').
I'm already using the builtin IPC channel for messaging and passing
named sockets around. But because I use privilege separation within my
server I also like to have an efficient pipe, like the socketpair that
is used when specifying 'pipe' in stdio, to push some binary data to the
child (in the form of BSON).
-Tim
On Sun, Oct 26, 2014 at 2:53 PM, Tim Kuijsten <[email protected]
<mailto:[email protected]>> wrote:
I would like to setup an IPC pipe with a submodule. Unfortunately it
seems impossible to provide a stdio array with fork like the way
this is done with spawn.
Two questions:
1. is the following equivalent to `fork('lib/foo')`?
spawn('node', ['lib/foo'], {
stdio: ['pipe', 'pipe', 'pipe', 'ipc']
});
2. should I use spawn when I want to share a pipe with a submodule? i.e.
spawn('node', ['lib/foo'], {
stdio: ['pipe', 'pipe', 'pipe', 'ipc', 'pipe']
});
-Tim
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/__othiym23/9886289#file-__moderation-policy-md
<https://gist.github.com/othiym23/9886289#file-moderation-policy-md>
Old group rules:
https://github.com/joyent/__node/wiki/Mailing-List-__Posting-Guidelines
<https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines>
--- You received this message because you are subscribed to the
Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to nodejs+unsubscribe@__googlegroups.com
<mailto:nodejs%[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/__msgid/nodejs/544D3522.4040904%__40netsend.nl
<https://groups.google.com/d/msgid/nodejs/544D3522.4040904%40netsend.nl>.
For more options, visit https://groups.google.com/d/__optout
<https://groups.google.com/d/optout>.
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/CAMs%2BDqKcJoxMQjz78Z%2BP5sn%2BvJqUmWffFykOw0wWQa%2BnjJB%3Dgw%40mail.gmail.com
<https://groups.google.com/d/msgid/nodejs/CAMs%2BDqKcJoxMQjz78Z%2BP5sn%2BvJqUmWffFykOw0wWQa%2BnjJB%3Dgw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/544E261D.90605%40netsend.nl.
For more options, visit https://groups.google.com/d/optout.