]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/tcsh/tc.sig.h
This commit was generated by cvs2svn to compensate for changes in r71756,
[FreeBSD/FreeBSD.git] / contrib / tcsh / tc.sig.h
1 /* $Header: /src/pub/tcsh/tc.sig.h,v 3.22 2000/11/11 23:03:39 christos Exp $ */
2 /*
3  * tc.sig.h: Signal handling
4  *
5  */
6 /*-
7  * Copyright (c) 1980, 1991 The Regents of the University of California.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *      This product includes software developed by the University of
21  *      California, Berkeley and its contributors.
22  * 4. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  */
38 #ifndef _h_tc_sig
39 #define _h_tc_sig
40
41 #if (SYSVREL > 0) || defined(BSD4_4) || defined(_MINIX) || defined(DGUX) || defined(WINNT_NATIVE)
42 # include <signal.h>
43 # ifndef SIGCHLD
44 #  define SIGCHLD SIGCLD
45 # endif /* SIGCHLD */
46 #else /* SYSVREL == 0 */
47 # include <sys/signal.h>
48 #endif /* SYSVREL > 0 */
49
50 #if defined(SUNOS4) || defined(DGUX) || defined(hp800) || (SYSVREL > 3 && defined(POSIXSIGS) && defined(VFORK))
51 # define SAVESIGVEC
52 #endif /* SUNOS4 || DGUX || hp800 || SVR4 & POSIXSIGS & VFORK */
53
54 #if (SYSVREL > 0 && SYSVREL < 3 && !defined(BSDSIGS)) || defined(_MINIX) || defined(COHERENT)
55 /*
56  * If we have unreliable signals...
57  */
58 # define UNRELSIGS
59 #endif /* SYSVREL > 0 && SYSVREL < 3 && !BSDSIGS || _MINIX || COHERENT */
60
61 #ifdef BSDSIGS
62 /*
63  * sigvec is not the same everywhere
64  */
65 # if defined(_SEQUENT_) || (defined(_POSIX_SOURCE) && !defined(hpux))
66 #  define HAVE_SIGVEC
67 #  define mysigvec(a, b, c)     sigaction(a, b, c)
68 typedef struct sigaction sigvec_t;
69 #  if defined(convex) || defined(__convex__)
70      /* eliminate compiler warnings since these are defined in signal.h  */
71 #    undef sv_handler
72 #    undef sv_flags
73 #  endif
74 #  define sv_handler sa_handler
75 #  define sv_flags sa_flags
76 # endif /* _SEQUENT || (_POSIX_SOURCE && !hpux) */
77
78 # ifdef hpux
79 #  define HAVE_SIGVEC
80 #  define mysigvec(a, b, c)     sigvector(a, b, c)
81 typedef struct sigvec sigvec_t;
82 #  define NEEDsignal
83 # endif /* hpux */
84
85 # ifndef HAVE_SIGVEC
86 #  ifdef POSIXSIGS
87 #  define mysigvec(a, b, c)     sigaction(a, b, c)
88 typedef struct sigaction sigvec_t;
89 #   define sv_handler sa_handler
90 #   define sv_flags sa_flags
91 #  else /* BSDSIGS */
92 #   define mysigvec(a, b, c)    sigvec(a, b, c)
93 typedef struct sigvec sigvec_t;
94 #  endif /* POSIXSIGS */
95 # endif /* HAVE_SIGVEC */
96
97 # undef HAVE_SIGVEC
98 #endif /* BSDSIGS */
99
100 #if SYSVREL > 0
101 # ifdef BSDJOBS
102 /* here I assume that systems that have bsdjobs implement the
103  * the setpgrp call correctly. Otherwise defining this would
104  * work, but it would kill the world, because all the setpgrp
105  * code is the the part defined when BSDJOBS are defined
106  * NOTE: we don't want killpg(a, b) == kill(-getpgrp(a), b)
107  * cause process a might be already dead and getpgrp would fail
108  */
109 #  define killpg(a, b) kill(-(a), (b))
110 # else
111 /* this is the poor man's version of killpg()! Just kill the
112  * current process and don't worry about the rest. Someday
113  * I hope I get to fix that.
114  */
115 #  define killpg(a, b) kill((a), (b))
116 # endif /* BSDJOBS */
117 #endif /* SYSVREL > 0 */
118
119 #ifdef _MINIX
120 # include <signal.h>
121 # define killpg(a, b) kill((a), (b))
122 # ifdef _MINIX_VMD
123 #  define signal(a, b) signal((a), (a) == SIGCHLD ? SIG_IGN : (b))
124 # endif /* _MINIX_VMD */
125 #endif /* _MINIX */
126
127 #ifdef _VMS_POSIX
128 # define killpg(a, b) kill(-(a), (b))
129 #endif /* atp _VMS_POSIX */
130
131 #if !defined(NSIG) && defined(SIGMAX)
132 # define NSIG (SIGMAX+1)
133 #endif /* !NSIG && SIGMAX */
134 #if !defined(NSIG) && defined(_SIG_MAX)
135 # define NSIG (_SIG_MAX+1)
136 #endif /* !NSIG && _SIG_MAX */
137 #if !defined(NSIG) && defined(_NSIG)
138 # define NSIG _NSIG
139 #endif /* !NSIG && _NSIG */
140 #if !defined(MAXSIG) && defined(NSIG)
141 # define MAXSIG NSIG
142 #endif /* !MAXSIG && NSIG */
143
144 #ifdef BSDSIGS
145 /*
146  * For 4.2bsd signals.
147  */
148 # ifdef sigmask
149 #  undef sigmask
150 # endif /* sigmask */
151 # define        sigmask(s)      (1 << ((s)-1))
152 # ifdef POSIXSIGS
153 #  define       sigpause(a)     (void) bsd_sigpause(a)
154 #  ifdef WINNT_NATIVE
155 #   undef signal
156 #  endif /* WINNT_NATIVE */
157 #  define       signal(a, b)    bsd_signal(a, b)
158 # endif /* POSIXSIGS */
159 # ifndef _SEQUENT_
160 #  define       sighold(s)      sigblock(sigmask(s))
161 #  define       sigignore(s)    signal(s, SIG_IGN)
162 #  define       sigset(s, a)    signal(s, a)
163 # endif /* !_SEQUENT_ */
164 # ifdef aiws
165 #  define       sigrelse(a)     sigsetmask(sigblock(0) & ~sigmask(a))
166 #  undef        killpg
167 #  define       killpg(a, b)    kill(-getpgrp(a), b)
168 #  define       NEEDsignal
169 # endif /* aiws */
170 #endif /* BSDSIGS */
171
172
173 /*
174  * We choose a define for the window signal if it exists..
175  */
176 #ifdef SIGWINCH
177 # define SIG_WINDOW SIGWINCH
178 #else
179 # ifdef SIGWINDOW
180 #  define SIG_WINDOW SIGWINDOW
181 # endif /* SIGWINDOW */
182 #endif /* SIGWINCH */
183
184 #ifdef convex
185 # ifdef notdef
186 /* Does not seem to work right... Christos */
187 #  define SIGSYNCH       0 
188 # endif
189 # ifdef SIGSYNCH
190 #  define SYNCHMASK     (sigmask(SIGCHLD)|sigmask(SIGSYNCH))
191 # else
192 #  define SYNCHMASK     (sigmask(SIGCHLD))
193 # endif
194 extern sigret_t synch_handler();
195 #endif /* convex */
196
197 #ifdef SAVESIGVEC
198 # define NSIGSAVED 7
199  /*
200   * These are not inline for speed. gcc -traditional -O on the sparc ignores
201   * the fact that vfork() corrupts the registers. Calling a routine is not
202   * nice, since it can make the compiler put some things that we want saved
203   * into registers                              - christos
204   */
205 # define savesigvec(sv)                                         \
206    ((void) mysigvec(SIGINT,  (sigvec_t *) 0, &(sv)[0]),         \
207     (void) mysigvec(SIGQUIT, (sigvec_t *) 0, &(sv)[1]),         \
208     (void) mysigvec(SIGTSTP, (sigvec_t *) 0, &(sv)[2]),         \
209     (void) mysigvec(SIGTTIN, (sigvec_t *) 0, &(sv)[3]),         \
210     (void) mysigvec(SIGTTOU, (sigvec_t *) 0, &(sv)[4]),         \
211     (void) mysigvec(SIGTERM, (sigvec_t *) 0, &(sv)[5]),         \
212     (void) mysigvec(SIGHUP,  (sigvec_t *) 0, &(sv)[6]),         \
213     sigblock(sigmask(SIGINT) | sigmask(SIGQUIT) |               \
214             sigmask(SIGTSTP) | sigmask(SIGTTIN) |               \
215             sigmask(SIGTTOU) | sigmask(SIGTERM) |               \
216             sigmask(SIGHUP)))
217
218 # define restoresigvec(sv, sm)                                  \
219     (void) ((void) mysigvec(SIGINT,  &(sv)[0], (sigvec_t *) 0), \
220             (void) mysigvec(SIGQUIT, &(sv)[1], (sigvec_t *) 0), \
221             (void) mysigvec(SIGTSTP, &(sv)[2], (sigvec_t *) 0), \
222             (void) mysigvec(SIGTTIN, &(sv)[3], (sigvec_t *) 0), \
223             (void) mysigvec(SIGTTOU, &(sv)[4], (sigvec_t *) 0), \
224             (void) mysigvec(SIGTERM, &(sv)[5], (sigvec_t *) 0), \
225             (void) mysigvec(SIGHUP,  &(sv)[6], (sigvec_t *) 0), \
226             (void) sigsetmask(sm))
227 # endif /* SAVESIGVEC */
228
229 #endif /* _h_tc_sig */