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:
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.