Re: safe shut-down



You can catch a lot of signal, except KILL.
No matter what you do, the user can send a SIGKILL to your process and stop
it without giving it a fair chance to clean.


Henri


"Michael T. Babcock" wrote:

In other words, consider trapping the TERM and KILL signals instead, doing
a fast clean-up (no asking questions) and then exit.

Havoc Pennington wrote:

Carlos Pereira <carlos pehoe civil ist utl pt> writes:
My app must be close with the close button (x button).
If the user launches the app in a console, he can close it
with crtl+c and this produces a non-safe shut-down.
How can I avoid this?

#include <signal.h>

/* to disable crtl+c */
signal (SIGINT, SIG_IGN);

/* to enable crtl+c */
signal(SIGINT, SIG_DFL);

This is AINSI C code, so it should really work everywhere.


Of course the user can still kill -9, and your app can still crash, so
you probably don't want to depend on disabling Ctrl-C.

--
Michael T. Babcock, C.T.O. FibreSpeed
http://www.fibrespeed.net/~mbabcock

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]