This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes Signal Handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Signal Handling" Watch "Signal Handling" New topic
Author

Signal Handling

Karthik Veeramani
Ranch Hand

Joined: Dec 22, 2002
Posts: 132
I have a java process that is started in background by a shell script. The script writes the PID of the process to a file, and later, a stop script can read the file and kill the process. When I start the process inside an xterm window, I find that the process dies when the window is closed. This happens only with xterm, and other shells dont seem to kill the process when they exit. I have some workarounds that involve modifying the shell script, but I need to do some kind of signal handling in the java code. Can any one tell me if it is possible to write a piece of java code, that makes sure the hangup signal is ignored.


Thanks<br />Karthik<br />SCJP 1.4, CCNA.<br /> <br />"Success is relative. More the success, more the relatives."
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
What about simply using "nohup" to start the java process?
- Peter
Karthik Veeramani
Ranch Hand

Joined: Dec 22, 2002
Posts: 132
Yep I did that. and it works. But then, the requirement is to modify the java code itself to take care of the signal. Thats the problem!
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
You might want to check out this article Revelations on Java signal handling and termination.
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
 
Don't get me started about those stupid light bulbs.
 
subject: Signal Handling