xref: /onnv-gate/usr/src/head/signal.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
23*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*0Sstevel@tonic-gate 
25*0Sstevel@tonic-gate 
26*0Sstevel@tonic-gate /*
27*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28*0Sstevel@tonic-gate  * Use is subject to license terms.
29*0Sstevel@tonic-gate  */
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate #ifndef _SIGNAL_H
32*0Sstevel@tonic-gate #define	_SIGNAL_H
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.5.3.4 */
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #include <sys/feature_tests.h>
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
39*0Sstevel@tonic-gate 	defined(__XOPEN_OR_POSIX)
40*0Sstevel@tonic-gate #include <sys/types.h>	/* need pid_t/uid_t/size_t/clock_t/caddr_t/pthread_t */
41*0Sstevel@tonic-gate #endif
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate #include <iso/signal_iso.h>
44*0Sstevel@tonic-gate #include <sys/signal.h>
45*0Sstevel@tonic-gate 
46*0Sstevel@tonic-gate /*
47*0Sstevel@tonic-gate  * Allow global visibility for symbols defined in
48*0Sstevel@tonic-gate  * C++ "std" namespace in <iso/signal_iso.h>.
49*0Sstevel@tonic-gate  */
50*0Sstevel@tonic-gate #if __cplusplus >= 199711L
51*0Sstevel@tonic-gate using std::sig_atomic_t;
52*0Sstevel@tonic-gate using std::signal;
53*0Sstevel@tonic-gate using std::raise;
54*0Sstevel@tonic-gate #endif
55*0Sstevel@tonic-gate 
56*0Sstevel@tonic-gate #ifdef	__cplusplus
57*0Sstevel@tonic-gate extern "C" {
58*0Sstevel@tonic-gate #endif
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate 
61*0Sstevel@tonic-gate #if defined(__STDC__)
62*0Sstevel@tonic-gate 
63*0Sstevel@tonic-gate extern const char	**_sys_siglistp;	/* signal descriptions */
64*0Sstevel@tonic-gate extern const int	_sys_siglistn;		/* # of signal descriptions */
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
67*0Sstevel@tonic-gate #define	_sys_siglist	_sys_siglistp
68*0Sstevel@tonic-gate #define	_sys_nsig	_sys_siglistn
69*0Sstevel@tonic-gate #endif
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
72*0Sstevel@tonic-gate 	defined(__XOPEN_OR_POSIX)
73*0Sstevel@tonic-gate extern int kill(pid_t, int);
74*0Sstevel@tonic-gate extern int sigaction(int, const struct sigaction *_RESTRICT_KYWD,
75*0Sstevel@tonic-gate 	struct sigaction *_RESTRICT_KYWD);
76*0Sstevel@tonic-gate #ifndef	_KERNEL
77*0Sstevel@tonic-gate extern int sigaddset(sigset_t *, int);
78*0Sstevel@tonic-gate extern int sigdelset(sigset_t *, int);
79*0Sstevel@tonic-gate extern int sigemptyset(sigset_t *);
80*0Sstevel@tonic-gate extern int sigfillset(sigset_t *);
81*0Sstevel@tonic-gate extern int sigismember(const sigset_t *, int);
82*0Sstevel@tonic-gate #endif
83*0Sstevel@tonic-gate extern int sigpending(sigset_t *);
84*0Sstevel@tonic-gate extern int sigprocmask(int, const sigset_t *_RESTRICT_KYWD,
85*0Sstevel@tonic-gate 	sigset_t *_RESTRICT_KYWD);
86*0Sstevel@tonic-gate extern int sigsuspend(const sigset_t *);
87*0Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC)... */
88*0Sstevel@tonic-gate 
89*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \
90*0Sstevel@tonic-gate 	!defined(__XOPEN_OR_POSIX))
91*0Sstevel@tonic-gate #include <sys/procset.h>
92*0Sstevel@tonic-gate extern int gsignal(int);
93*0Sstevel@tonic-gate extern int (*ssignal(int, int (*)(int)))(int);
94*0Sstevel@tonic-gate extern int sigsend(idtype_t, id_t, int);
95*0Sstevel@tonic-gate extern int sigsendset(const procset_t *, int);
96*0Sstevel@tonic-gate extern int sig2str(int, char *);
97*0Sstevel@tonic-gate extern int str2sig(const char *, int *);
98*0Sstevel@tonic-gate #define	SIG2STR_MAX	32
99*0Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC)... */
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \
102*0Sstevel@tonic-gate 	!defined(__XOPEN_OR_POSIX)) || defined(_XPG4_2)
103*0Sstevel@tonic-gate extern void (*bsd_signal(int, void (*)(int)))(int);
104*0Sstevel@tonic-gate extern int killpg(pid_t, int);
105*0Sstevel@tonic-gate extern int siginterrupt(int, int);
106*0Sstevel@tonic-gate extern int sigaltstack(const stack_t *_RESTRICT_KYWD, stack_t *_RESTRICT_KYWD);
107*0Sstevel@tonic-gate extern int sighold(int);
108*0Sstevel@tonic-gate extern int sigignore(int);
109*0Sstevel@tonic-gate extern int sigpause(int);
110*0Sstevel@tonic-gate extern int sigrelse(int);
111*0Sstevel@tonic-gate extern void (*sigset(int, void (*)(int)))(int);
112*0Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && ... */
113*0Sstevel@tonic-gate 
114*0Sstevel@tonic-gate /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
115*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || \
116*0Sstevel@tonic-gate 	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
117*0Sstevel@tonic-gate 	(defined(_XPG4_2) && !defined(_XPG6))
118*0Sstevel@tonic-gate extern int sigstack(struct sigstack *, struct sigstack *);
119*0Sstevel@tonic-gate #endif
120*0Sstevel@tonic-gate 
121*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \
122*0Sstevel@tonic-gate 	!defined(__XOPEN_OR_POSIX)) || (_POSIX_C_SOURCE > 2)
123*0Sstevel@tonic-gate #include <sys/siginfo.h>
124*0Sstevel@tonic-gate #include <time.h>
125*0Sstevel@tonic-gate extern int pthread_kill(pthread_t, int);
126*0Sstevel@tonic-gate extern int pthread_sigmask(int, const sigset_t *_RESTRICT_KYWD,
127*0Sstevel@tonic-gate 	sigset_t *_RESTRICT_KYWD);
128*0Sstevel@tonic-gate extern int sigwaitinfo(const sigset_t *_RESTRICT_KYWD,
129*0Sstevel@tonic-gate 	siginfo_t *_RESTRICT_KYWD);
130*0Sstevel@tonic-gate extern int sigtimedwait(const sigset_t *_RESTRICT_KYWD,
131*0Sstevel@tonic-gate 	siginfo_t *_RESTRICT_KYWD, const struct timespec *_RESTRICT_KYWD);
132*0Sstevel@tonic-gate extern int sigqueue(pid_t, int, const union sigval);
133*0Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && */
134*0Sstevel@tonic-gate 
135*0Sstevel@tonic-gate #else	/* __STDC__ */
136*0Sstevel@tonic-gate 
137*0Sstevel@tonic-gate extern char	**_sys_siglistp;	/* signal descriptions */
138*0Sstevel@tonic-gate extern int	_sys_siglistn;		/* # of signal descriptions */
139*0Sstevel@tonic-gate 
140*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
141*0Sstevel@tonic-gate #define	_sys_siglist	_sys_siglistp
142*0Sstevel@tonic-gate #define	_sys_nsig	_sys_siglistn
143*0Sstevel@tonic-gate #endif
144*0Sstevel@tonic-gate 
145*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || defined(__XOPEN_OR_POSIX)
146*0Sstevel@tonic-gate extern int kill();
147*0Sstevel@tonic-gate extern int sigaction();
148*0Sstevel@tonic-gate #ifndef	_KERNEL
149*0Sstevel@tonic-gate extern int sigaddset();
150*0Sstevel@tonic-gate extern int sigdelset();
151*0Sstevel@tonic-gate extern int sigemptyset();
152*0Sstevel@tonic-gate extern int sigfillset();
153*0Sstevel@tonic-gate extern int sigismember();
154*0Sstevel@tonic-gate #endif
155*0Sstevel@tonic-gate extern int sigpending();
156*0Sstevel@tonic-gate extern int sigprocmask();
157*0Sstevel@tonic-gate extern int sigsuspend();
158*0Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__)... */
159*0Sstevel@tonic-gate 
160*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
161*0Sstevel@tonic-gate 	defined(_XPG4_2)
162*0Sstevel@tonic-gate extern void (*bsd_signal())();
163*0Sstevel@tonic-gate extern int killpg();
164*0Sstevel@tonic-gate extern int siginterrupt();
165*0Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) ... */
166*0Sstevel@tonic-gate 
167*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
168*0Sstevel@tonic-gate 	(defined(_XPG4_2) && !defined(_XPG6))
169*0Sstevel@tonic-gate extern int sigstack();
170*0Sstevel@tonic-gate #endif
171*0Sstevel@tonic-gate 
172*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
173*0Sstevel@tonic-gate extern int gsignal();
174*0Sstevel@tonic-gate extern int (*ssignal)();
175*0Sstevel@tonic-gate extern int sigsend();
176*0Sstevel@tonic-gate extern int sigsendset();
177*0Sstevel@tonic-gate extern int sig2str();
178*0Sstevel@tonic-gate extern int str2sig();
179*0Sstevel@tonic-gate #define	SIG2STR_MAX	32
180*0Sstevel@tonic-gate #endif
181*0Sstevel@tonic-gate 
182*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
183*0Sstevel@tonic-gate 	defined(_XPG4_2)
184*0Sstevel@tonic-gate extern int sigaltstack();
185*0Sstevel@tonic-gate extern int sighold();
186*0Sstevel@tonic-gate extern int sigignore();
187*0Sstevel@tonic-gate extern int sigpause();
188*0Sstevel@tonic-gate extern int sigrelse();
189*0Sstevel@tonic-gate extern void (*sigset())();
190*0Sstevel@tonic-gate #endif
191*0Sstevel@tonic-gate 
192*0Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
193*0Sstevel@tonic-gate 	(_POSIX_C_SOURCE > 2)
194*0Sstevel@tonic-gate #include <sys/siginfo.h>
195*0Sstevel@tonic-gate #include <sys/time.h>
196*0Sstevel@tonic-gate extern int pthread_kill();
197*0Sstevel@tonic-gate extern int pthread_sigmask();
198*0Sstevel@tonic-gate extern int sigwaitinfo();
199*0Sstevel@tonic-gate extern int sigtimedwait();
200*0Sstevel@tonic-gate extern int sigqueue();
201*0Sstevel@tonic-gate #endif
202*0Sstevel@tonic-gate 
203*0Sstevel@tonic-gate #endif	/* __STDC__ */
204*0Sstevel@tonic-gate 
205*0Sstevel@tonic-gate /*
206*0Sstevel@tonic-gate  * sigwait() prototype is defined here.
207*0Sstevel@tonic-gate  */
208*0Sstevel@tonic-gate 
209*0Sstevel@tonic-gate #if	defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \
210*0Sstevel@tonic-gate 	!defined(__XOPEN_OR_POSIX)) || (_POSIX_C_SOURCE - 0 >= 199506L) || \
211*0Sstevel@tonic-gate 	defined(_POSIX_PTHREAD_SEMANTICS)
212*0Sstevel@tonic-gate 
213*0Sstevel@tonic-gate #if	defined(__STDC__)
214*0Sstevel@tonic-gate 
215*0Sstevel@tonic-gate #if	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
216*0Sstevel@tonic-gate 
217*0Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME
218*0Sstevel@tonic-gate #pragma redefine_extname sigwait __posix_sigwait
219*0Sstevel@tonic-gate extern int sigwait(const sigset_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
220*0Sstevel@tonic-gate #else  /* __PRAGMA_REDEFINE_EXTNAME */
221*0Sstevel@tonic-gate 
222*0Sstevel@tonic-gate extern int __posix_sigwait(const sigset_t *_RESTRICT_KYWD,
223*0Sstevel@tonic-gate     int *_RESTRICT_KYWD);
224*0Sstevel@tonic-gate 
225*0Sstevel@tonic-gate #ifdef	__lint
226*0Sstevel@tonic-gate #define	sigwait __posix_sigwait
227*0Sstevel@tonic-gate #else	/* !__lint */
228*0Sstevel@tonic-gate 
229*0Sstevel@tonic-gate static int
sigwait(const sigset_t * _RESTRICT_KYWD __setp,int * _RESTRICT_KYWD __signo)230*0Sstevel@tonic-gate sigwait(const sigset_t *_RESTRICT_KYWD __setp, int *_RESTRICT_KYWD __signo)
231*0Sstevel@tonic-gate {
232*0Sstevel@tonic-gate 	return (__posix_sigwait(__setp, __signo));
233*0Sstevel@tonic-gate }
234*0Sstevel@tonic-gate 
235*0Sstevel@tonic-gate #endif /* !__lint */
236*0Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */
237*0Sstevel@tonic-gate 
238*0Sstevel@tonic-gate #else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
239*0Sstevel@tonic-gate 
240*0Sstevel@tonic-gate extern int sigwait(sigset_t *);
241*0Sstevel@tonic-gate 
242*0Sstevel@tonic-gate #endif  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
243*0Sstevel@tonic-gate 
244*0Sstevel@tonic-gate 
245*0Sstevel@tonic-gate #else  /* __STDC__ */
246*0Sstevel@tonic-gate 
247*0Sstevel@tonic-gate 
248*0Sstevel@tonic-gate #if	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
249*0Sstevel@tonic-gate 
250*0Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME
251*0Sstevel@tonic-gate #pragma redefine_extname sigwait __posix_sigwait
252*0Sstevel@tonic-gate extern int sigwait();
253*0Sstevel@tonic-gate #else  /* __PRAGMA_REDEFINE_EXTNAME */
254*0Sstevel@tonic-gate 
255*0Sstevel@tonic-gate extern int __posix_sigwait();
256*0Sstevel@tonic-gate 
257*0Sstevel@tonic-gate #ifdef	__lint
258*0Sstevel@tonic-gate #define	sigwait __posix_sigwait
259*0Sstevel@tonic-gate #else	/* !__lint */
260*0Sstevel@tonic-gate 
261*0Sstevel@tonic-gate static int
sigwait(__setp,__signo)262*0Sstevel@tonic-gate sigwait(__setp, __signo)
263*0Sstevel@tonic-gate 	sigset_t *__setp;
264*0Sstevel@tonic-gate 	int *__signo;
265*0Sstevel@tonic-gate {
266*0Sstevel@tonic-gate 	return (__posix_sigwait(__setp, __signo));
267*0Sstevel@tonic-gate }
268*0Sstevel@tonic-gate 
269*0Sstevel@tonic-gate #endif /* !__lint */
270*0Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */
271*0Sstevel@tonic-gate 
272*0Sstevel@tonic-gate #else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
273*0Sstevel@tonic-gate 
274*0Sstevel@tonic-gate extern int sigwait();
275*0Sstevel@tonic-gate 
276*0Sstevel@tonic-gate #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
277*0Sstevel@tonic-gate 
278*0Sstevel@tonic-gate #endif /* __STDC__ */
279*0Sstevel@tonic-gate 
280*0Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */
281*0Sstevel@tonic-gate 
282*0Sstevel@tonic-gate #ifdef	__cplusplus
283*0Sstevel@tonic-gate }
284*0Sstevel@tonic-gate #endif
285*0Sstevel@tonic-gate 
286*0Sstevel@tonic-gate #endif	/* _SIGNAL_H */
287