Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

kill child process

Status
Not open for further replies.

Lars

Programmer
Aug 10, 2000
16
DE
Hello !

I want to start to start other programs from my java program. To do this I use the following code:
.
.
Runtime rt = Runtime.getRuntime();
proc = rt.exec(progName);
proc.waitFor();
.
.
When I end my program I also want all the programs started
by my program to be ended too. I tried
.
proc.destroy();
.
This works fine for real executables, but does not for
shell scripts that again start java programs. With those
my program ends but the others keep running.
Is there any way to kill all sub processes? the problem is
the program should be able to run on Linux and Windows.

Thanks



 
In the past I've had a tiny semaphore file in a common location that all my programs would check periodically. If one of the program wrote a "kill" value to the file, the others would read it and know they should shut down. I needed to do this because I had several java apps running as services under NT, and needed to shut them down at a particular time every morning (but still have them close down gracefully and not just cancel them in mid-method). "When you have eliminated the impossible, whatever remains, however
improbable, must be the truth." ~ Arthur Conan Doyle
 
The problem is that those other program are not written by me.
My program just starts a shell script which then executes another java program...for example IBM Eclipse. When I shutdown my program I also want Eclipse to shutdown too. I
cannot modify Eclipse to check for a shutdown file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top