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?
/proc/<pid>/fd/0
would get you a handle on pid's stdin but what would you do with that? What if it's a terminal device, a regular file, a socket, a pipe? Here, it looks like you wantfoo.js
stdin to be a pipe (or other IPC channel like a socketpair) andbar.js
to have a file descriptor to the other end of that pipe.