1 /* $Header: /src/pub/tcsh/tc.sig.h,v 3.22 2000/11/11 23:03:39 christos Exp $ */
3 * tc.sig.h: Signal handling
7 * Copyright (c) 1980, 1991 The Regents of the University of California.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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
41 #if (SYSVREL > 0) || defined(BSD4_4) || defined(_MINIX) || defined(DGUX) || defined(WINNT_NATIVE)
44 # define SIGCHLD SIGCLD
46 #else /* SYSVREL == 0 */
47 # include <sys/signal.h>
48 #endif /* SYSVREL > 0 */
50 #if defined(SUNOS4) || defined(DGUX) || defined(hp800) || (SYSVREL > 3 && defined(POSIXSIGS) && defined(VFORK))
52 #endif /* SUNOS4 || DGUX || hp800 || SVR4 & POSIXSIGS & VFORK */
54 #if (SYSVREL > 0 && SYSVREL < 3 && !defined(BSDSIGS)) || defined(_MINIX) || defined(COHERENT)
56 * If we have unreliable signals...
59 #endif /* SYSVREL > 0 && SYSVREL < 3 && !BSDSIGS || _MINIX || COHERENT */
63 * sigvec is not the same everywhere
65 # if defined(_SEQUENT_) || (defined(_POSIX_SOURCE) && !defined(hpux))
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 */
74 # define sv_handler sa_handler
75 # define sv_flags sa_flags
76 # endif /* _SEQUENT || (_POSIX_SOURCE && !hpux) */
80 # define mysigvec(a, b, c) sigvector(a, b, c)
81 typedef struct sigvec sigvec_t;
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
92 # define mysigvec(a, b, c) sigvec(a, b, c)
93 typedef struct sigvec sigvec_t;
94 # endif /* POSIXSIGS */
95 # endif /* HAVE_SIGVEC */
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
109 # define killpg(a, b) kill(-(a), (b))
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.
115 # define killpg(a, b) kill((a), (b))
116 # endif /* BSDJOBS */
117 #endif /* SYSVREL > 0 */
121 # define killpg(a, b) kill((a), (b))
123 # define signal(a, b) signal((a), (a) == SIGCHLD ? SIG_IGN : (b))
124 # endif /* _MINIX_VMD */
128 # define killpg(a, b) kill(-(a), (b))
129 #endif /* atp _VMS_POSIX */
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)
139 #endif /* !NSIG && _NSIG */
140 #if !defined(MAXSIG) && defined(NSIG)
142 #endif /* !MAXSIG && NSIG */
146 * For 4.2bsd signals.
150 # endif /* sigmask */
151 # define sigmask(s) (1 << ((s)-1))
153 # define sigpause(a) (void) bsd_sigpause(a)
156 # endif /* WINNT_NATIVE */
157 # define signal(a, b) bsd_signal(a, b)
158 # endif /* POSIXSIGS */
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_ */
165 # define sigrelse(a) sigsetmask(sigblock(0) & ~sigmask(a))
167 # define killpg(a, b) kill(-getpgrp(a), b)
174 * We choose a define for the window signal if it exists..
177 # define SIG_WINDOW SIGWINCH
180 # define SIG_WINDOW SIGWINDOW
181 # endif /* SIGWINDOW */
182 #endif /* SIGWINCH */
186 /* Does not seem to work right... Christos */
190 # define SYNCHMASK (sigmask(SIGCHLD)|sigmask(SIGSYNCH))
192 # define SYNCHMASK (sigmask(SIGCHLD))
194 extern sigret_t synch_handler();
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
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) | \
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 */
229 #endif /* _h_tc_sig */