I have some code in which proc = Runtime.getRuntime().exec(cmd)
is called to launch a subprocess, and then there is some communication between the parent and child processes. In some cases, I'm getting java.io.IOException: The pipe is being closed
during calls to write() and flush() from the parent to the child. This happens sometimes but not every time.
My hypothesis here is that the subprocess is being launched (and therefore proc.getInput/OutputStream()
works) but the parent process is trying to write to the child process before the child process is fully running/executing. Does this seem plausible? I don't have enough deep experience with the JVM to really feel confident. Currently my solution is to have the child process write to the parent, informing it that it's up and running; this works perfectly fine, but it would be nice to feel a bit more confident about it.
If any more code details or whatever are needed, I'd be happy to supply.
Thanks!