1

Say I have

node foo.js | node bar.js

is there a way to pass a handle on foo's stdin to bar?

I have a rare case where I'd like to communicate backwards in the pipeline.

At the least I know that I could send node bar.js the pid of node foo.js. Given that pid, on *nix, I should be able to write to foo's stdin using:

/proc/<pid>/fd/0

but is there a way to do the same on MacOS?

8

1 Answer 1

1

In the general case no, because the write handle of the stdin of foo is only in the hands of its parent process (foo only sees the read handle)... You have to set up a specific pipe (anonymous or FIFO) between the two; and this is better anyway because you don't know what would happen if bar wrote to that handle as the same time as foo's parent.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .