I am starting a process from node with child_process.spawn and handling process.stdout/stderr data events, and writing to stdin.

Now, my node application may crash or get stopped, when it is restarted I find the process by it's PID, and then I would like to attach again to the process' stdin/stderr/stdout.

The process in question could be any daemon-like program, so I do not have control over it's behaviour (I cannot set up the process to redirect it's stdio upon receiving a signal, for example).

I am thinking wrapping the process using screen, redirecting stdio to a FIFO file (but the customFds option is deprecated in node 6), but none of that seems as clean as process.stdin.on...

Edit
Report