tags:

views:

55

answers:

1

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:

  1. Create a second socket (probably from the C server back to the Java server) where in I just send stderr back over.
  2. 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.

A: 

To solve this, I took advantage of the fact that the two servers are running on the same machine. I merely wrote the stderr to a file which I read in the other server. Not the most elegant solution in the world, but quite simple and it works.

Morinar