you can access the new file-descriptor from C simply as 3, the index of
extra 'pipe'.  for example:
   read(3, buf, sizeof(buf))
   write(3, buf, sizeof(buf))
   fcntl(3, ...)

i usually give my programs command-line arguments for the file descriptor,
as it feels a bit ugly to hard-code the relationship.  But, there's plenty
of precedence for hard-coding as well.

On Mon, Dec 18, 2017 at 1:44 PM, Mike Aubury <[email protected]> wrote:

> Hi,
> I want to be able to communicate with a C program while maintaining stdio
> streams as-is - sort of like the way NodeJS can send messages to child
> nodejs programs.
>
> I can see in the documentation - i can use something like :
>
>
>    spawn('prg', [], { stdio: ['pipe', 'pipe', 'pipe', 'pipe' /* extra one
> here */] });
>
>
> But - what do i need to do on the C side to link back to that new pipe ?
> Do I need 2 pipes (one for read, one for write)
>
> Am I better trying to do something with IPC ?
>
> Any ideas, and/or code samples would be greatly appreciated !
>
>
> --
> 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/12b181e7-ad06-4c98-88e6-de7e0959409f%40googlegroups.com
> <https://groups.google.com/d/msgid/nodejs/12b181e7-ad06-4c98-88e6-de7e0959409f%40googlegroups.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/CADJQ9xLiPSWw%2BB5gN%3D36ywJXvShNfxBp-ykzzqqQdsg3XOPJLw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to