Good evening. I'm having issues related to subprocesses.

What I'm trying to do is launch another program that has a command-line mode (Gnucap, in case it matters) as a child process from my Java program, then communicate with it by reading from its standard output and writing to its command line. When I launch the child process, however, I find that when I try to read from the child's standard output, it only reads up until the end of the last complete line of output before the command prompt. After that, when I try to read the next byte from the child's standard output, the read() function blocks forever. Writing anything (including a newline) to the child's standard input at any point in this process has no effect.

I have used Java's built-in Process class, Apache Commons Exec, and ExpectJ. In all three cases, the same problem happens.

What can I do? Thanks for your time.

Also, I'm on Linux. (I should have mentioned this, since I understand that behavior of child process I/O can be OS dependent.)