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