|
|
1.1 root 1: /*
2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * The contents of this file constitute Original Code as defined in and
7: * are subject to the Apple Public Source License Version 1.1 (the
8: * "License"). You may not use this file except in compliance with the
9: * License. Please obtain a copy of the License at
10: * http://www.apple.com/publicsource and read it before using this file.
11: *
12: * This Original Code and all software distributed under the License are
13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17: * License for the specific language governing rights and limitations
18: * under the License.
19: *
20: * @APPLE_LICENSE_HEADER_END@
21: */
22: /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
23: /*
24: * Copyright (c) 1982, 1986, 1989, 1993, 1994
25: * The Regents of the University of California. All rights reserved.
26: *
27: * Redistribution and use in source and binary forms, with or without
28: * modification, are permitted provided that the following conditions
29: * are met:
30: * 1. Redistributions of source code must retain the above copyright
31: * notice, this list of conditions and the following disclaimer.
32: * 2. Redistributions in binary form must reproduce the above copyright
33: * notice, this list of conditions and the following disclaimer in the
34: * documentation and/or other materials provided with the distribution.
35: * 3. All advertising materials mentioning features or use of this software
36: * must display the following acknowledgement:
37: * This product includes software developed by the University of
38: * California, Berkeley and its contributors.
39: * 4. Neither the name of the University nor the names of its contributors
40: * may be used to endorse or promote products derived from this software
41: * without specific prior written permission.
42: *
43: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
44: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
47: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53: * SUCH DAMAGE.
54: *
55: * @(#)wait.h 8.2 (Berkeley) 7/10/94
56: */
57:
58: #ifndef _SYS_WAIT_H_
59: #define _SYS_WAIT_H_
60:
61: /*
62: * This file holds definitions relevent to the wait4 system call
63: * and the alternate interfaces that use it (wait, wait3, waitpid).
64: */
65:
66: /*
67: * Macros to test the exit status returned by wait
68: * and extract the relevant values.
69: */
70: #ifdef _POSIX_SOURCE
71: #define _W_INT(i) (i)
72: #else
73: #define _W_INT(w) (*(int *)&(w)) /* convert union wait to int */
74: #define WCOREFLAG 0200
75:
76: #endif /* _POSIX_SOURCE */
77:
78: #define _WSTATUS(x) (_W_INT(x) & 0177)
79: #define _WSTOPPED 0177 /* _WSTATUS if process is stopped */
80: #define WIFSTOPPED(x) (_WSTATUS(x) == _WSTOPPED)
81: #define WSTOPSIG(x) (_W_INT(x) >> 8)
82: #define WIFSIGNALED(x) (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
83: #define WTERMSIG(x) (_WSTATUS(x))
84: #define WIFEXITED(x) (_WSTATUS(x) == 0)
85: #define WEXITSTATUS(x) (_W_INT(x) >> 8)
86: #if !defined(_POSIX_SOURCE)
87: #define WCOREDUMP(x) (_W_INT(x) & WCOREFLAG)
88:
89: #define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
90: #define W_STOPCODE(sig) ((sig) << 8 | _WSTOPPED)
91: #endif /* !defined(_POSIX_SOURCE) */
92:
93: /*
94: * Option bits for the third argument of wait4. WNOHANG causes the
95: * wait to not hang if there are no stopped or terminated processes, rather
96: * returning an error indication in this case (pid==0). WUNTRACED
97: * indicates that the caller should receive status about untraced children
98: * which stop due to signals. If children are stopped and a wait without
99: * this option is done, it is as though they were still running... nothing
100: * about them is returned.
101: */
102: #define WNOHANG 1 /* don't hang in wait */
103: #define WUNTRACED 2 /* tell about stopped, untraced children */
104:
105: #if !defined(_POSIX_SOURCE)
106: /* POSIX extensions and 4.2/4.3 compatability: */
107:
108: /*
109: * Tokens for special values of the "pid" parameter to wait4.
110: */
111: #define WAIT_ANY (-1) /* any process */
112: #define WAIT_MYPGRP 0 /* any process in my process group */
113:
114: #include <machine/endian.h>
115:
116: /*
117: * Deprecated:
118: * Structure of the information in the status word returned by wait4.
119: * If w_stopval==WSTOPPED, then the second structure describes
120: * the information returned, else the first.
121: */
122: union wait {
123: int w_status; /* used in syscall */
124: /*
125: * Terminated process status.
126: */
127: struct {
128: #if BYTE_ORDER == LITTLE_ENDIAN
129: unsigned int w_Termsig:7, /* termination signal */
130: w_Coredump:1, /* core dump indicator */
131: w_Retcode:8, /* exit code if w_termsig==0 */
132: w_Filler:16; /* upper bits filler */
133: #endif
134: #if BYTE_ORDER == BIG_ENDIAN
135: unsigned int w_Filler:16, /* upper bits filler */
136: w_Retcode:8, /* exit code if w_termsig==0 */
137: w_Coredump:1, /* core dump indicator */
138: w_Termsig:7; /* termination signal */
139: #endif
140: } w_T;
141: /*
142: * Stopped process status. Returned
143: * only for traced children unless requested
144: * with the WUNTRACED option bit.
145: */
146: struct {
147: #if BYTE_ORDER == LITTLE_ENDIAN
148: unsigned int w_Stopval:8, /* == W_STOPPED if stopped */
149: w_Stopsig:8, /* signal that stopped us */
150: w_Filler:16; /* upper bits filler */
151: #endif
152: #if BYTE_ORDER == BIG_ENDIAN
153: unsigned int w_Filler:16, /* upper bits filler */
154: w_Stopsig:8, /* signal that stopped us */
155: w_Stopval:8; /* == W_STOPPED if stopped */
156: #endif
157: } w_S;
158: };
159: #define w_termsig w_T.w_Termsig
160: #define w_coredump w_T.w_Coredump
161: #define w_retcode w_T.w_Retcode
162: #define w_stopval w_S.w_Stopval
163: #define w_stopsig w_S.w_Stopsig
164:
165: #define WSTOPPED _WSTOPPED
166: #endif /* !defined(_POSIX_SOURCE) */
167:
168: #ifndef KERNEL
169: #include <sys/types.h>
170: #include <sys/cdefs.h>
171:
172: __BEGIN_DECLS
173: struct rusage; /* forward declaration */
174:
175: pid_t wait __P((int *));
176: pid_t waitpid __P((pid_t, int *, int));
177: #if !defined(_POSIX_SOURCE)
178: pid_t wait3 __P((int *, int, struct rusage *));
179: pid_t wait4 __P((pid_t, int *, int, struct rusage *));
180: #endif /* !defined(_POSIX_SOURCE) */
181: __END_DECLS
182: #endif
183: #endif /* !_SYS_WAIT_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.