H
Henning Moll
Hi!
I have a big problem with the following code:
---code---
import java.io.*;
public class DDD {
public static void main(String[] args) throws IOException
{
String command = "/path_to/bbb";
/* bbb is a shell script containing the following lines:
* ---snip---
* #!/bin/sh
* sleep 333
* echo done
* ---snip---
*/
Process pr = Runtime.getRuntime().exec(command);
int b;
while((b = pr.getInputStream().read()) != -1)
{
System.out.print((char)b);
}
}
}
---code---
No problem if we just wait the 333 seconds. The program prints 'done' an exits. But:
If you kill the script while the sleep is running, read() doesn't return ever.
(Note: kill the script, not the sleep process!).
What am i doing wrong? How to handle this?
Henning
I have a big problem with the following code:
---code---
import java.io.*;
public class DDD {
public static void main(String[] args) throws IOException
{
String command = "/path_to/bbb";
/* bbb is a shell script containing the following lines:
* ---snip---
* #!/bin/sh
* sleep 333
* echo done
* ---snip---
*/
Process pr = Runtime.getRuntime().exec(command);
int b;
while((b = pr.getInputStream().read()) != -1)
{
System.out.print((char)b);
}
}
}
---code---
No problem if we just wait the 333 seconds. The program prints 'done' an exits. But:
If you kill the script while the sleep is running, read() doesn't return ever.
(Note: kill the script, not the sleep process!).
What am i doing wrong? How to handle this?
Henning