I'm currently writing something to work around this Java bug:
http://bugs.sun.com/view_bug.do?bug_id=5049299
Basically, I've got a light weight C server that runs on the same machine as the Java server. I'm adding a feature to the C server when I can request it to fork/run a new process via a socket and pass back stdin/stdout/stderr. On the Java side, I've created something that mimics the behavior of ProcessBuilder
and Runtime.exec()
, but over the socket.
The problem arises with stderr
. Java sockets don't have an error stream, so I'm at a bit of a loss as to how to get it back over. I've come up with two potential solutions:
- Create a second socket (probably from the C server back to the Java server) where in I just send stderr back over.
- Interleave the output of process with the stderr of the process and then parse them apart in the Java back into separate streams
Both solutions have inherent problems, so I'd love to hear any feedback anybody has.
BONUS: Give me an easy, guaranteed solution to the Java bug that doesn't involve me doing any of this and I'll be your best friend forever.