xref: /titanic_50/usr/src/lib/libshell/common/include/fault.h (revision fc80c0dfb0c877aee828d778ea32b77fcf7b1ef4)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *           Copyright (c) 1982-2007 AT&T Knowledge Ventures            *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                      by AT&T Knowledge Ventures                      *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *            http://www.opensource.org/licenses/cpl1.0.txt             *
11 *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                  David Korn <dgk@research.att.com>                   *
18 *                                                                      *
19 ***********************************************************************/
20 #pragma prototyped
21 #ifndef SH_SIGBITS
22 /*
23  *	UNIX shell
24  *	S. R. Bourne
25  *	Rewritten by David Korn
26  *
27  */
28 
29 #include	<sig.h>
30 #include	<setjmp.h>
31 #include	<error.h>
32 #include	<sfio.h>
33 #include	"FEATURE/setjmp"
34 #include	"FEATURE/sigfeatures"
35 
36 #ifndef SIGWINCH
37 #   ifdef SIGWIND
38 #	define SIGWINCH	SIGWIND
39 #   else
40 #	ifdef SIGWINDOW
41 #	    define SIGWINCH	SIGWINDOW
42 #	endif
43 #   endif
44 #endif
45 
46 typedef void (*SH_SIGTYPE)(int,void(*)(int));
47 
48 #define SH_FORKLIM		16	/* fork timeout interval */
49 
50 #define SH_TRAP			0200	/* bit for internal traps */
51 #define SH_ERRTRAP		0	/* trap for non-zero exit status */
52 #define SH_KEYTRAP		1	/* trap for keyboard event */
53 #define SH_DEBUGTRAP		4	/* must be last internal trap */
54 
55 #define SH_SIGBITS		8
56 #define SH_SIGFAULT		1	/* signal handler is sh_fault */
57 #define SH_SIGOFF		2	/* signal handler is SIG_IGN */
58 #define SH_SIGSET		4	/* pending signal */
59 #define SH_SIGTRAP		010	/* pending trap */
60 #define SH_SIGDONE		020	/* default is exit */
61 #define SH_SIGIGNORE		040	/* default is ingore signal */
62 #define SH_SIGINTERACTIVE	0100	/* handle interactive specially */
63 #define SH_SIGTSTP		0200	/* tstp signal received */
64 #define SH_SIGALRM		0200	/* timer alarm received */
65 #define SH_SIGTERM		SH_SIGOFF /* term signal received */
66 
67 /*
68  * These are longjmp values
69  */
70 
71 #define SH_JMPDOT	2
72 #define SH_JMPEVAL	3
73 #define SH_JMPTRAP	4
74 #define SH_JMPIO	5
75 #define SH_JMPCMD	6
76 #define SH_JMPFUN	7
77 #define SH_JMPERRFN	8
78 #define SH_JMPSUB	9
79 #define SH_JMPERREXIT	10
80 #define SH_JMPEXIT	11
81 #define SH_JMPSCRIPT	12
82 
83 struct openlist
84 {
85 	Sfio_t	*strm;
86 	struct openlist *next;
87 };
88 
89 struct checkpt
90 {
91 	sigjmp_buf	buff;
92 	sigjmp_buf	*prev;
93 	int		topfd;
94 	int		mode;
95 	struct openlist	*olist;
96 #if (ERROR_VERSION >= 20030214L)
97 	Error_context_t err;
98 #else
99 	struct errorcontext err;
100 #endif
101 };
102 
103 #define sh_pushcontext(bp,n)	( (bp)->mode=(n) , (bp)->olist=0,  \
104 				  (bp)->topfd=sh.topfd, (bp)->prev=sh.jmplist, \
105 				  (bp)->err = *ERROR_CONTEXT_BASE, \
106 					sh.jmplist = (sigjmp_buf*)(&(bp)->buff) \
107 				)
108 #define sh_popcontext(bp)	(sh.jmplist=(bp)->prev, errorpop(&((bp)->err)))
109 
110 extern void 	sh_fault(int);
111 extern void 	sh_done(int);
112 extern void 	sh_chktrap(void);
113 extern void 	sh_sigclear(int);
114 extern void 	sh_sigdone(void);
115 extern void	sh_siginit(void);
116 extern void 	sh_sigtrap(int);
117 extern void 	sh_sigreset(int);
118 extern void 	sh_timetraps(void);
119 extern void 	*sh_timeradd(unsigned long,int ,void (*)(void*),void*);
120 extern void	timerdel(void*);
121 
122 extern const char e_alarm[];
123 
124 #endif /* !SH_SIGBITS */
125