Posted By:
Mirek_Subrt
Posted On:
Friday, April 19, 2002 06:14 AM
I am calling some non-Java-program from my Java code: Process process = Runtime.getRuntime().exec(command); .......... int code=waitFor(); // or code=exitValue(); I want to detect at my Java code that the non-Java-program (at command, say "prg.exe") was killed outside of Java environment. A) When the kill is done during I/O-operations of prg.exe, then I can detect by IOException (it is OK). B) When the kill is done during waitFor, then I can detect by InterruptedException (it is OK, too). C) But when the kill is done in other place of Java-code, I DO NOT how to detect that the prg.exe was KILLed!
More>>
I am calling some non-Java-program from my Java code:
Process process = Runtime.getRuntime().exec(command);
..........
int code=waitFor(); // or code=exitValue();
I want to detect at my Java code that the non-Java-program
(at command, say "prg.exe") was killed outside of Java environment.
A) When the kill is done during I/O-operations of prg.exe, then I can detect by IOException (it is OK).
B) When the kill is done during waitFor,
then I can detect by InterruptedException (it is OK, too).
C) But when the kill is done in other place of Java-code, I DO NOT how to detect that the prg.exe was KILLed!
When I kill program prg.exe, then my method waitFor (and exitValue) return 1. But it depends on concrete program (for prg1.exe it can be 0, for example !!).
And how can I distinguish the exitValue=1 in these 2 situations:
1) prg.exe finished normally (it was not killed), but it indicated some his inner state by return 1;
2) prg.exe has killed from the outside.
Thanks in advance for your help!
Mirek
<<Less