2006-08-18 17:03:41 +00:00
|
|
|
/*
|
|
|
|
cleanup.c , Copyright 2006 Thomas Schmitt <scdbackup@gmx.net>
|
|
|
|
|
|
|
|
A signal handler which cleans up an application and exits.
|
|
|
|
|
2006-10-03 16:37:08 +00:00
|
|
|
Provided under GPL license within GPL projects, BSD license elsewise.
|
2006-08-18 17:03:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef Cleanup_includeD
|
|
|
|
#define Cleanup_includeD 1
|
|
|
|
|
|
|
|
|
|
|
|
/** Layout of an application provided cleanup function using an application
|
|
|
|
provided handle as first argument and the signal number as second
|
|
|
|
argument. The third argument is a flag bit field with no defined bits yet.
|
2006-10-03 16:37:08 +00:00
|
|
|
If the handler returns 2 or -2 then it has delegated exit() to some other
|
2006-08-18 17:03:41 +00:00
|
|
|
instance and the Cleanup handler shall return rather than exit.
|
|
|
|
*/
|
|
|
|
typedef int (*Cleanup_app_handler_T)(void *, int, int);
|
|
|
|
|
|
|
|
|
|
|
|
/** Establish exiting signal handlers on (hopefully) all signals that are
|
|
|
|
not ignored by default or non-catchable.
|
|
|
|
@param handle Opaque object which knows how to cleanup application
|
|
|
|
@param handler Function which uses handle to perform application cleanup
|
|
|
|
@param flag Control Bitfield
|
|
|
|
bit0= reset to default signal handling
|
|
|
|
*/
|
|
|
|
int Cleanup_set_handlers(void *handle, Cleanup_app_handler_T handler,
|
|
|
|
int flag);
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* ! Cleanup_includeD */
|
|
|
|
|