Sending control codes to native program

Hello,

I execute a native application with Runtime.getRuntime().exec(), but the application does not return from proc.waitFor(). I feed the application from stdin. Other applications (e.g. cat) runs fine, so believe I have to terminate the input with a CTRL+D or something like this, but it does not work. How can I send a control code to the process?

I tried:

write('\u0004')

write('\u0003')

But why returns:

write('\u000D');

write('\u000A);

an error in the IDE?

Process proc = Runtime.getRuntime().exec(cmd+"\u0004");

BufferedInputStream bufferedIn = new BufferedInputStream(in);

outStream = new BufferedOutputStream(proc.getOutputStream());

errorStream = new BufferedReader(new InputStreamReader(proc

.getErrorStream()));

inStream = new BufferedReader(new InputStreamReader(proc

.getInputStream()));

int b;

while ((b = bufferedIn.read()) != -1) {

outStream.write(b);

}

proc.waitFor();

Thanks, Karsten

[1043 byte] By [widerstanda] at [2007-10-3 4:55:43]
# 1
\u000D is \r\u000A is \n
ejpa at 2007-7-14 23:00:54 > top of Java-index,Core,Core APIs...
# 2
Yes. I Know. I only wanted to know why Eclipse complains. But this is not the problem. waitFor() does not return.
widerstanda at 2007-7-14 23:00:54 > top of Java-index,Core,Core APIs...
# 3
Close outStream when you get the -1.
ejpa at 2007-7-14 23:00:54 > top of Java-index,Core,Core APIs...
# 4

Does not help. I flush and close the stream. Same result.

The program which does not work is a C program and waits until feof() says it. So, I also thought closing the stream would help to get an EOF, but it doesn't.

Message was edited by:

widerstand

Message was edited by:

widerstand

widerstanda at 2007-7-14 23:00:54 > top of Java-index,Core,Core APIs...
# 5
You will need to read all the process's output on both stdout and stderr. It's probably blocked there.
ejpa at 2007-7-14 23:00:54 > top of Java-index,Core,Core APIs...
# 6
Great! Thanks. This was it. I created 3 Threads for each stream.
widerstanda at 2007-7-14 23:00:54 > top of Java-index,Core,Core APIs...