wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Forcibly Shutting Java Program Down Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Forcibly Shutting Java Program Down " Watch "Forcibly Shutting Java Program Down " New topic
Author

Forcibly Shutting Java Program Down

Seth Burleigh
Greenhorn

Joined: Jul 25, 2009
Posts: 7
I have a program (actually an eclipse plugin) that has to shut down a program even if it becomes frozen and the user has to use ctrl+alt+delete. If the java program is
shut down using this and the java program doesn't shut down a certain program that it was using via a socket (sbcl.exe), sbcl.exe suddenly starts sucking down resources (50 percent
or more of cpu). I don't want the user to have to use ctrl+alt+delete to shut down sbcl also. So my question is, is there anyway to make sure that this program shuts down when the java program shuts down (forcibly)?
Thanks!
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

When you forcibly stop a program, that program doesn't get any chance to do anything before the operating system stops it. There is nothing you can do inside your Java program to make it stop the other program (sbcl.exe) when the Java program is forcibly stopped.

What you could do is make a small third program, which periodically checks if the Java program is still running or if it has been shut down cleanly. If it isn't running and hasn't shutdown cleanly, then that third program kills sbcl.exe.

Don't you have the source code of sbcl.exe? Isn't it strange that it starts sucking up resources if the Java program isn't running?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Seth Burleigh
Greenhorn

Joined: Jul 25, 2009
Posts: 7
Ya, it is strange, but sbcl.exe is a reputable open source software. And I can run it outside my java program, and it doesn't suck down resources. So i think it is safe. Thanks, i will try that solution.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Forcibly Shutting Java Program Down