source: trunk/third/tcsh/tc.sig.h @ 12039

Revision 12039, 7.4 KB checked in by danw, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12038, which included commits to RCS files with non-trunk default branches.
Line 
1/* $Header: /afs/dev.mit.edu/source/repository/third/tcsh/tc.sig.h,v 1.1.1.2 1998-10-03 21:10:15 danw 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)
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)
68typedef 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)
81typedef 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)
88typedef 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)
93typedef 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#endif /* _MINIX */
123
124#ifdef _VMS_POSIX
125# define killpg(a, b) kill(-(a), (b))
126#endif /* atp _VMS_POSIX */
127
128#if !defined(NSIG) && defined(SIGMAX)
129# define NSIG (SIGMAX+1)
130#endif /* !NSIG && SIGMAX */
131#if !defined(NSIG) && defined(_SIG_MAX)
132# define NSIG (_SIG_MAX+1)
133#endif /* !NSIG && _SIG_MAX */
134#if !defined(NSIG) && defined(_NSIG)
135# define NSIG _NSIG
136#endif /* !NSIG && _NSIG */
137#if !defined(MAXSIG) && defined(NSIG)
138# define MAXSIG NSIG
139#endif /* !MAXSIG && NSIG */
140
141#ifdef BSDSIGS
142/*
143 * For 4.2bsd signals.
144 */
145# ifdef sigmask
146#  undef sigmask
147# endif /* sigmask */
148# define        sigmask(s)      (1 << ((s)-1))
149# ifdef POSIXSIGS
150#  define       sigpause(a)     (void) bsd_sigpause(a)
151#  ifdef WINNT
152#   undef signal
153#  endif /* WINNT */
154#  define       signal(a, b)    bsd_signal(a, b)
155# endif /* POSIXSIGS */
156# ifndef _SEQUENT_
157#  define       sighold(s)      sigblock(sigmask(s))
158#  define       sigignore(s)    signal(s, SIG_IGN)
159#  define       sigset(s, a)    signal(s, a)
160# endif /* !_SEQUENT_ */
161# ifdef aiws
162#  define       sigrelse(a)     sigsetmask(sigblock(0) & ~sigmask(a))
163#  undef        killpg
164#  define       killpg(a, b)    kill(-getpgrp(a), b)
165#  define       NEEDsignal
166# endif /* aiws */
167#endif /* BSDSIGS */
168
169
170/*
171 * We choose a define for the window signal if it exists..
172 */
173#ifdef SIGWINCH
174# define SIG_WINDOW SIGWINCH
175#else
176# ifdef SIGWINDOW
177#  define SIG_WINDOW SIGWINDOW
178# endif /* SIGWINDOW */
179#endif /* SIGWINCH */
180
181#ifdef convex
182# ifdef notdef
183/* Does not seem to work right... Christos */
184#  define SIGSYNCH       0
185# endif
186# ifdef SIGSYNCH
187#  define SYNCHMASK     (sigmask(SIGCHLD)|sigmask(SIGSYNCH))
188# else
189#  define SYNCHMASK     (sigmask(SIGCHLD))
190# endif
191extern sigret_t synch_handler();
192#endif /* convex */
193
194#ifdef SAVESIGVEC
195# define NSIGSAVED 7
196 /*
197  * These are not inline for speed. gcc -traditional -O on the sparc ignores
198  * the fact that vfork() corrupts the registers. Calling a routine is not
199  * nice, since it can make the compiler put some things that we want saved
200  * into registers                              - christos
201  */
202# define savesigvec(sv)                                         \
203   ((void) mysigvec(SIGINT,  (sigvec_t *) 0, &(sv)[0]),         \
204    (void) mysigvec(SIGQUIT, (sigvec_t *) 0, &(sv)[1]),         \
205    (void) mysigvec(SIGTSTP, (sigvec_t *) 0, &(sv)[2]),         \
206    (void) mysigvec(SIGTTIN, (sigvec_t *) 0, &(sv)[3]),         \
207    (void) mysigvec(SIGTTOU, (sigvec_t *) 0, &(sv)[4]),         \
208    (void) mysigvec(SIGTERM, (sigvec_t *) 0, &(sv)[5]),         \
209    (void) mysigvec(SIGHUP,  (sigvec_t *) 0, &(sv)[6]),         \
210    sigblock(sigmask(SIGINT) | sigmask(SIGQUIT) |               \
211            sigmask(SIGTSTP) | sigmask(SIGTTIN) |               \
212            sigmask(SIGTTOU) | sigmask(SIGTERM) |               \
213            sigmask(SIGHUP)))
214
215# define restoresigvec(sv, sm)                                  \
216    (void) ((void) mysigvec(SIGINT,  &(sv)[0], (sigvec_t *) 0), \
217            (void) mysigvec(SIGQUIT, &(sv)[1], (sigvec_t *) 0), \
218            (void) mysigvec(SIGTSTP, &(sv)[2], (sigvec_t *) 0), \
219            (void) mysigvec(SIGTTIN, &(sv)[3], (sigvec_t *) 0), \
220            (void) mysigvec(SIGTTOU, &(sv)[4], (sigvec_t *) 0), \
221            (void) mysigvec(SIGTERM, &(sv)[5], (sigvec_t *) 0), \
222            (void) mysigvec(SIGHUP,  &(sv)[6], (sigvec_t *) 0), \
223            (void) sigsetmask(sm))
224# endif /* SAVESIGVEC */
225
226#endif /* _h_tc_sig */
Note: See TracBrowser for help on using the repository browser.