954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Communicating with a child process

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.

JDCyrus
Light Poster
27 posts since Jun 2008
Reputation Points: 10
Solved Threads: 2
 

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

JDCyrus
Light Poster
27 posts since Jun 2008
Reputation Points: 10
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: