xref: /titanic_44/usr/src/uts/common/sys/wait.h (revision 87308b749adb04ab3f564c765b089962af3edb4d)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 /*
26  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
27  *
28  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
29  * Use is subject to license terms.
30  */
31 
32 #ifndef _SYS_WAIT_H
33 #define	_SYS_WAIT_H
34 
35 #include <sys/feature_tests.h>
36 
37 #include <sys/types.h>
38 
39 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
40 #include <sys/resource.h>	/* Added for XSH4.2 */
41 #include <sys/siginfo.h>
42 #include <sys/procset.h>
43 #endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) ... */
44 
45 #ifdef	__cplusplus
46 extern "C" {
47 #endif
48 
49 /*
50  * arguments to wait functions
51  */
52 
53 #define	WUNTRACED	0004	/* wait for processes stopped by signals */
54 #define	WNOHANG		0100	/* non blocking form of wait	*/
55 
56 
57 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
58 #define	WEXITED		0001	/* wait for processes that have exited	*/
59 #define	WTRAPPED	0002	/* wait for processes stopped while tracing */
60 #define	WSTOPPED	WUNTRACED /* backwards compatibility */
61 #define	WCONTINUED	0010	/* wait for processes continued */
62 #define	WNOWAIT		0200	/* non destructive form of wait */
63 #define	WOPTMASK (WEXITED|WTRAPPED|WSTOPPED|WCONTINUED|WNOHANG|WNOWAIT)
64 #endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) ... */
65 
66 /*
67  * macros for stat return from wait functions
68  */
69 
70 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
71 
72 #define	WSTOPFLG		0177
73 #define	WCONTFLG		0177777
74 #define	WCOREFLG		0200
75 #define	WSIGMASK		0177
76 
77 #define	WLOBYTE(stat)		((int)((stat)&0377))
78 #define	WHIBYTE(stat)		((int)(((stat)>>8)&0377))
79 #define	WWORD(stat)		((int)((stat))&0177777)
80 
81 #define	WIFCONTINUED(stat)	(WWORD(stat) == WCONTFLG)
82 #define	WCOREDUMP(stat)		((stat)&WCOREFLG)
83 
84 #endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) ... */
85 
86 #define	WIFEXITED(stat)		((int)((stat)&0xFF) == 0)
87 #define	WIFSIGNALED(stat)	((int)((stat)&0xFF) > 0 && \
88 				    (int)((stat)&0xFF00) == 0)
89 #define	WIFSTOPPED(stat)	((int)((stat)&0xFF) == 0177 && \
90 				    (int)((stat)&0xFF00) != 0)
91 #define	WEXITSTATUS(stat)	((int)(((stat)>>8)&0xFF))
92 #define	WTERMSIG(stat)		((int)((stat)&0x7F))
93 #define	WSTOPSIG(stat)		((int)(((stat)>>8)&0xFF))
94 
95 
96 #if !defined(_KERNEL)
97 
98 extern pid_t wait(int *);
99 extern pid_t waitpid(pid_t, int *, int);
100 
101 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
102 extern int waitid(idtype_t, id_t, siginfo_t *, int);
103 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
104 #if !defined(_XPG6) || defined(__EXTENSIONS__)
105 extern pid_t wait3(int *, int, struct rusage *);
106 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
107 #endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) ... */
108 
109 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
110 extern pid_t wait4(pid_t, int *, int, struct rusage *);
111 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
112 
113 #endif	/* _KERNEL */
114 
115 #ifdef	__cplusplus
116 }
117 #endif
118 
119 #endif	/* _SYS_WAIT_H */
120