1 /* -----------------------------------------------------------------
2 "@(#) cleanup.h (Yale) version 1.6 11/2/91"
3 FILE:	    cleanup.h
4 DESCRIPTION:This file contains include file for cleanup handler
5 	    routines.  To use cleanup handler included '<signal.h>'
6 	    at the top of main.c and #define CLEANUP_C either by
7 	    uncommenting the define in this file or by setting the
8 	    variable in the makefile: -DCLEANUP_H.  In addition,
9 	    the first executable line of the program must be
10 	    INITCLEANUP() macro.  In order for the handler to work,
11 	    the INITCLEANUP call must occur in the top level routine,
12 	    ie., main.c .
13 CONTENTS:   MACRO DEFINITIONS
14 DATE:	    Feb  2, 1988
15 REVISIONS:  Mar  9, 1989 - modified conditional compiles so you can
16 		avoid compilation on foreign machines.
17 ----------------------------------------------------------------- */
18 /* cleanup.h definitions for cleanup handler system */
19 
20 /* makefile sets this variable automatically but you can manually */
21 /* define it here if you want and your system supports UNIX signals */
22 /* #define CLEANUP_C - we want a cleanup handler. */
23 
24 #ifndef CLEANUP_H
25 #define CLEANUP_H
26 
27 #define NODUMP 0
28 #define YESDUMP 1
29 #define MAYBEDUMP 2
30 
31 #ifdef CLEANUP_C
32 #include <signal.h>
33 #include <yalecad/base.h>
34 
35 #ifdef linux
36 extern void Ycleanup(int);
37 #else
38 extern void Ycleanup(int, int, struct sigcontext *);
39 #endif
40 
41 /* initialization cleanup macro */
42 /* first  argument - argv[0] - program name */
43 /* second argument - function - user function that will be executed upon
44    fault */
45 /* third argument - dumpFlag - allows users to control core dump */
46 /*    signal(SIGQUIT,cleanup); - remove due to dbx bug */
47 /*    signal(SIGINT,cleanup); - remove due to dbx bug */
48 #define YINITCLEANUP( argv, function, dumpFlag ) \
49 {                                               \
50     signal(SIGHUP,Ycleanup); \
51     signal(SIGILL,Ycleanup);\
52     signal(SIGFPE,Ycleanup);\
53     signal(SIGSEGV,Ycleanup);\
54     signal(SIGBUS,Ycleanup);\
55     signal(SIGSYS,Ycleanup);\
56     signal(SIGTERM,Ycleanup);\
57     signal(SIGUSR1,Ycleanup);\
58     YinitCleanup( argv, function, dumpFlag ) ; \
59 }
60 
61 /*---------------------------------------------------------
62    initCleanup - sets static variables for cleanup handler.
63   --------------------------------------------------------*/
64 VOID YinitCleanup( P3(char *argv, BOOL (*function)(), int dump) );
65 
66 #else
67 
68 /* no cleanup handler - null it out */
69 #define YINITCLEANUP( argv, function, dumpFlag )
70 
71 #endif /* CLEANUP_C */
72 #endif /* CLEANUP_H */
73