I have a project that should be run forever under unix. But in case we need to stop it, i am thinking about writing an termination program to close it gracefully.
I have no experience in writing this kind of program.
Could anyone please give me some hint. Is there any signal catching scheme in java?
Thank you
I have a project that should be run forever under unix. But in case
Share
There are a couple of options here.
One is that you could have it accept command line input, but that would require you have access to it’s input stream which may not happen if you close the terminal etc. What is probably the best way to do this is to use either a socket and have it listen for a specific stream in order to shut down. Your termination program would then be responsible for writing to that socket.
Another option would be to use some sort of more complex IPC like shared memory.
And finally another option would be to use a flat file stored somewhere on the system that your process would monitor for changes. The termination program would then write to that file.