ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Yes it's possible, but it is not needed. The shutdown command send a signal to init telling it to shutdown. init will send all process a SIGTERM signal. This signal notifies all the process that they need to shutdown. It's the process's responsibility to shut its self down and it has five seconds to do so. After five seconds, init will send a SIGKILL to all the process. This will unconditionally kill all the processes.
Now if programs do not catch the SIGTERM process and do what is necessary to exit, then one can say that the program is either poorly written or preparing to exit is not necessary. It's all up the person who wrote the program to exit correctly.
Yes I agree with you. But let’s take an example, Assume I am editing a document with some Word-processing application and it receives a SIGTERM signal, What happens! I think the application must popup with a confirmation window asking to save the document or even with a window asking for a filename. If user don't respond, As you told the OS waits for five seconds and will kill the application with out saving the document.
This is just my assumption, what are your view on this
I see your point now. I missed it the first time since I have not run a GUI in years, and I'm not accustom to seeing that type of behavior.
The only think I can think of off hand, would be to write a daemon that could catch SIGTERM signals and wait for yes/no popup windows selecting yes to any that pop up. I have not touched X in a while, so I'm not really sure if it's possible.
I'm not sure but isn't this supposed to work even in X.
If for example you didn't save before and actuaööy don't have name for the document then doesn't linux save an auto-save file with it's own name. Can this be?
I don't know of any web sites, but I can recommend a great unix book. "Advanced Programming in the Unix Environment" by Stevens. As for X, the last I ever touched it was writing Sun openlook stuff about 4 years ago, and I can't remember what I used as a reference.
The previous post by ugge was absolutely right. If (like in your example), a word processing document receives a SIGTERM, it will assume the system is shutting down, and should do an auto-save rather than prompting the user asking if they want to save. When the application is then restarted it should ask the user if they would like to revert back to the previous session. If a program, be it a GUI program, commandline or daemon doesn't do this, it should really be considered shoddy programming, and an alternative needs to be found. You shouldn't have to write your own daemon applications to deal with this, as it should already be covered.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.