xref: /illumos-gate/usr/src/head/signal.h (revision 8329232e)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
23b4203d75SMarcel Telka /*	  All Rights Reserved	*/
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate /*
26ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
27ba3594baSGarrett D'Amore  *
287c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
297c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
307c478bd9Sstevel@tonic-gate  */
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifndef _SIGNAL_H
337c478bd9Sstevel@tonic-gate #define	_SIGNAL_H
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
387c478bd9Sstevel@tonic-gate 	defined(__XOPEN_OR_POSIX)
397c478bd9Sstevel@tonic-gate #include <sys/types.h>	/* need pid_t/uid_t/size_t/clock_t/caddr_t/pthread_t */
407c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #include <iso/signal_iso.h>
437c478bd9Sstevel@tonic-gate #include <sys/signal.h>
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate  * Allow global visibility for symbols defined in
477c478bd9Sstevel@tonic-gate  * C++ "std" namespace in <iso/signal_iso.h>.
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L
507c478bd9Sstevel@tonic-gate using std::sig_atomic_t;
517c478bd9Sstevel@tonic-gate using std::signal;
527c478bd9Sstevel@tonic-gate using std::raise;
537c478bd9Sstevel@tonic-gate #endif
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
567c478bd9Sstevel@tonic-gate extern "C" {
577c478bd9Sstevel@tonic-gate #endif
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate extern const char	**_sys_siglistp;	/* signal descriptions */
617c478bd9Sstevel@tonic-gate extern const int	_sys_siglistn;		/* # of signal descriptions */
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
647c478bd9Sstevel@tonic-gate #define	_sys_siglist	_sys_siglistp
657c478bd9Sstevel@tonic-gate #define	_sys_nsig	_sys_siglistn
667c478bd9Sstevel@tonic-gate #endif
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
697c478bd9Sstevel@tonic-gate 	defined(__XOPEN_OR_POSIX)
707c478bd9Sstevel@tonic-gate extern int kill(pid_t, int);
717c478bd9Sstevel@tonic-gate extern int sigaction(int, const struct sigaction *_RESTRICT_KYWD,
727c478bd9Sstevel@tonic-gate 	struct sigaction *_RESTRICT_KYWD);
73*8329232eSGordon Ross #if !defined(_KERNEL) && !defined(_FAKE_KERNEL)
747c478bd9Sstevel@tonic-gate extern int sigaddset(sigset_t *, int);
757c478bd9Sstevel@tonic-gate extern int sigdelset(sigset_t *, int);
767c478bd9Sstevel@tonic-gate extern int sigemptyset(sigset_t *);
777c478bd9Sstevel@tonic-gate extern int sigfillset(sigset_t *);
787c478bd9Sstevel@tonic-gate extern int sigismember(const sigset_t *, int);
797c478bd9Sstevel@tonic-gate #endif
807c478bd9Sstevel@tonic-gate extern int sigpending(sigset_t *);
817c478bd9Sstevel@tonic-gate extern int sigprocmask(int, const sigset_t *_RESTRICT_KYWD,
827c478bd9Sstevel@tonic-gate 	sigset_t *_RESTRICT_KYWD);
837c478bd9Sstevel@tonic-gate extern int sigsuspend(const sigset_t *);
847c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC)... */
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \
877c478bd9Sstevel@tonic-gate 	!defined(__XOPEN_OR_POSIX))
887c478bd9Sstevel@tonic-gate #include <sys/procset.h>
897c478bd9Sstevel@tonic-gate extern int gsignal(int);
907c478bd9Sstevel@tonic-gate extern int (*ssignal(int, int (*)(int)))(int);
917c478bd9Sstevel@tonic-gate extern int sigsend(idtype_t, id_t, int);
927c478bd9Sstevel@tonic-gate extern int sigsendset(const procset_t *, int);
937c478bd9Sstevel@tonic-gate extern int sig2str(int, char *);
947c478bd9Sstevel@tonic-gate extern int str2sig(const char *, int *);
957c478bd9Sstevel@tonic-gate #define	SIG2STR_MAX	32
967c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC)... */
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \
997c478bd9Sstevel@tonic-gate 	!defined(__XOPEN_OR_POSIX)) || defined(_XPG4_2)
1007c478bd9Sstevel@tonic-gate extern void (*bsd_signal(int, void (*)(int)))(int);
1017c478bd9Sstevel@tonic-gate extern int killpg(pid_t, int);
1027c478bd9Sstevel@tonic-gate extern int siginterrupt(int, int);
1037c478bd9Sstevel@tonic-gate extern int sigaltstack(const stack_t *_RESTRICT_KYWD, stack_t *_RESTRICT_KYWD);
1047c478bd9Sstevel@tonic-gate extern int sighold(int);
1057c478bd9Sstevel@tonic-gate extern int sigignore(int);
1067c478bd9Sstevel@tonic-gate extern int sigpause(int);
1077c478bd9Sstevel@tonic-gate extern int sigrelse(int);
1087c478bd9Sstevel@tonic-gate extern void (*sigset(int, void (*)(int)))(int);
1097c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && ... */
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
1127c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || \
1137c478bd9Sstevel@tonic-gate 	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
1147c478bd9Sstevel@tonic-gate 	(defined(_XPG4_2) && !defined(_XPG6))
1157c478bd9Sstevel@tonic-gate extern int sigstack(struct sigstack *, struct sigstack *);
1167c478bd9Sstevel@tonic-gate #endif
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \
1197c478bd9Sstevel@tonic-gate 	!defined(__XOPEN_OR_POSIX)) || (_POSIX_C_SOURCE > 2)
1207c478bd9Sstevel@tonic-gate #include <sys/siginfo.h>
1217c478bd9Sstevel@tonic-gate #include <time.h>
1227c478bd9Sstevel@tonic-gate extern int pthread_kill(pthread_t, int);
1237c478bd9Sstevel@tonic-gate extern int pthread_sigmask(int, const sigset_t *_RESTRICT_KYWD,
1247c478bd9Sstevel@tonic-gate 	sigset_t *_RESTRICT_KYWD);
1257c478bd9Sstevel@tonic-gate extern int sigwaitinfo(const sigset_t *_RESTRICT_KYWD,
1267c478bd9Sstevel@tonic-gate 	siginfo_t *_RESTRICT_KYWD);
1277c478bd9Sstevel@tonic-gate extern int sigtimedwait(const sigset_t *_RESTRICT_KYWD,
1287c478bd9Sstevel@tonic-gate 	siginfo_t *_RESTRICT_KYWD, const struct timespec *_RESTRICT_KYWD);
1297c478bd9Sstevel@tonic-gate extern int sigqueue(pid_t, int, const union sigval);
1307c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && */
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate /*
1337c478bd9Sstevel@tonic-gate  * sigwait() prototype is defined here.
1347c478bd9Sstevel@tonic-gate  */
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate #if	defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \
1377c478bd9Sstevel@tonic-gate 	!defined(__XOPEN_OR_POSIX)) || (_POSIX_C_SOURCE - 0 >= 199506L) || \
1387c478bd9Sstevel@tonic-gate 	defined(_POSIX_PTHREAD_SEMANTICS)
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate #if	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME
1437c478bd9Sstevel@tonic-gate #pragma redefine_extname sigwait __posix_sigwait
1447c478bd9Sstevel@tonic-gate extern int sigwait(const sigset_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
1457c478bd9Sstevel@tonic-gate #else  /* __PRAGMA_REDEFINE_EXTNAME */
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate extern int __posix_sigwait(const sigset_t *_RESTRICT_KYWD,
1487c478bd9Sstevel@tonic-gate     int *_RESTRICT_KYWD);
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate #ifdef	__lint
1517c478bd9Sstevel@tonic-gate #define	sigwait __posix_sigwait
1527c478bd9Sstevel@tonic-gate #else	/* !__lint */
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate static int
sigwait(const sigset_t * _RESTRICT_KYWD __setp,int * _RESTRICT_KYWD __signo)1557c478bd9Sstevel@tonic-gate sigwait(const sigset_t *_RESTRICT_KYWD __setp, int *_RESTRICT_KYWD __signo)
1567c478bd9Sstevel@tonic-gate {
1577c478bd9Sstevel@tonic-gate 	return (__posix_sigwait(__setp, __signo));
1587c478bd9Sstevel@tonic-gate }
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate #endif /* !__lint */
1617c478bd9Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate #else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate extern int sigwait(sigset_t *);
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate #endif  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1727c478bd9Sstevel@tonic-gate }
1737c478bd9Sstevel@tonic-gate #endif
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate #endif	/* _SIGNAL_H */
176