On a Linux machine, if I have the pid of a process, I can write to the stdin of that process using something like:
/proc/<pid>/fd/0
but on MacOS, this doesn't appear possible. I am told that I should use mkfifo / named pipes.
However using named pipes is making the problem harder to solve. Is there a way on MacOS to store a reference to a fd on the filesystem if you control the start of the process?
For example, if I do:
#!/usr/bin/env node
node script.js &
NODEJS_PID=$!
I can easily get the pid of this process, represented above by the NODEJS_PID var. However, is there a way to capture a reference to the file descriptor of the stdin to this nodejs process?
If I can get the path to the fd that would be cool, because I need to write to that fd from another process altogether.