Re: safe shut-down



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.

Havoc




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