t2ex/bsd_source/lib/libc/src_bsd/include/sys/wait.h | bare source | permlink (0.02 seconds) |
1: /* $OpenBSD: wait.h,v 1.14 2006/04/27 02:17:21 tedu Exp $ */ 2: /* $NetBSD: wait.h,v 1.11 1996/04/09 20:55:51 cgd Exp $ */ 3: 4: /* 5: * Copyright (c) 1982, 1986, 1989, 1993, 1994 6: * The Regents of the University of California. All rights reserved. 7: * 8: * Redistribution and use in source and binary forms, with or without 9: * modification, are permitted provided that the following conditions 10: * are met: 11: * 1. Redistributions of source code must retain the above copyright 12: * notice, this list of conditions and the following disclaimer. 13: * 2. Redistributions in binary form must reproduce the above copyright 14: * notice, this list of conditions and the following disclaimer in the 15: * documentation and/or other materials provided with the distribution. 16: * 3. Neither the name of the University nor the names of its contributors 17: * may be used to endorse or promote products derived from this software 18: * without specific prior written permission. 19: * 20: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30: * SUCH DAMAGE. 31: * 32: * @(#)wait.h 8.2 (Berkeley) 7/10/94 33: */ 34: 35: #ifndef _SYS_WAIT_H_ 36: #define _SYS_WAIT_H_ 37: 38: #include <sys/cdefs.h> 39: 40: /* 41: * This file holds definitions relevent to the wait4 system call 42: * and the alternate interfaces that use it (wait, wait3, waitpid). 43: */ 44: 45: /* 46: * Macros to test the exit status returned by wait 47: * and extract the relevant values. 48: */ 49: #if __BSD_VISIBLE 50: #define _W_INT(w) (*(int *)&(w)) /* convert union wait to int */ 51: #else 52: #define _W_INT(i) (i) 53: #endif 54: 55: #define _WSTATUS(x) (_W_INT(x) & 0177) 56: #define _WSTOPPED 0177 /* _WSTATUS if process is stopped */ 57: #define _WCONTINUED 0177777 /* process has continued */ 58: #define WIFSTOPPED(x) ((_W_INT(x) & 0xff) == _WSTOPPED) 59: #define WSTOPSIG(x) (int)(((unsigned)_W_INT(x) >> 8) & 0xff) 60: #define WIFSIGNALED(x) (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0) 61: #define WTERMSIG(x) (_WSTATUS(x)) 62: #define WIFEXITED(x) (_WSTATUS(x) == 0) 63: #define WEXITSTATUS(x) (int)(((unsigned)_W_INT(x) >> 8) & 0xff) 64: #define WIFCONTINUED(x) ((_W_INT(x) & _WCONTINUED) == _WCONTINUED) 65: #if __XPG_VISIBLE 66: #define WCOREFLAG 0200 67: #define WCOREDUMP(x) (_W_INT(x) & WCOREFLAG) 68: 69: #define W_EXITCODE(ret, sig) ((ret) << 8 | (sig)) 70: #define W_STOPCODE(sig) ((sig) << 8 | _WSTOPPED) 71: #endif 72: 73: /* 74: * Option bits for the third argument of wait4. WNOHANG causes the 75: * wait to not hang if there are no stopped or terminated processes, rather 76: * returning an error indication in this case (pid==0). WUNTRACED 77: * indicates that the caller should receive status about untraced children 78: * which stop due to signals. If children are stopped and a wait without 79: * this option is done, it is as though they were still running... nothing 80: * about them is returned. 81: */ 82: #define WNOHANG 1 /* don't hang in wait */ 83: #define WUNTRACED 2 /* tell about stopped, untraced children */ 84: #if __XPG_VISIBLE 85: #define WALTSIG 4 /* wait for child with alternate exit signal */ 86: #endif 87: #define WCONTINUED 8 /* report a job control continued process */ 88: 89: #if __BSD_VISIBLE 90: /* 91: * Tokens for special values of the "pid" parameter to wait4. 92: */ 93: #define WAIT_ANY (-1) /* any process */ 94: #define WAIT_MYPGRP 0 /* any process in my process group */ 95: 96: #include <sys/types.h> 97: 98: /* 99: * Deprecated: 100: * Structure of the information in the status word returned by wait4. 101: * If w_stopval==WSTOPPED, then the second structure describes 102: * the information returned, else the first. 103: */ 104: union wait { 105: int w_status; /* used in syscall */ 106: /* 107: * Terminated process status. 108: */ 109: struct { 110: #if _BYTE_ORDER == _LITTLE_ENDIAN 111: unsigned int w_Termsig:7, /* termination signal */ 112: w_Coredump:1, /* core dump indicator */ 113: w_Retcode:8, /* exit code if w_termsig==0 */ 114: w_Filler:16; /* upper bits filler */ 115: #endif 116: #if _BYTE_ORDER == _BIG_ENDIAN 117: unsigned int w_Filler:16, /* upper bits filler */ 118: w_Retcode:8, /* exit code if w_termsig==0 */ 119: w_Coredump:1, /* core dump indicator */ 120: w_Termsig:7; /* termination signal */ 121: #endif 122: } w_T; 123: /* 124: * Stopped process status. Returned 125: * only for traced children unless requested 126: * with the WUNTRACED option bit. 127: */ 128: struct { 129: #if _BYTE_ORDER == _LITTLE_ENDIAN 130: unsigned int w_Stopval:8, /* == W_STOPPED if stopped */ 131: w_Stopsig:8, /* signal that stopped us */ 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_Stopsig:8, /* signal that stopped us */ 137: w_Stopval:8; /* == W_STOPPED if stopped */ 138: #endif 139: } w_S; 140: }; 141: #define w_termsig w_T.w_Termsig 142: #define w_coredump w_T.w_Coredump 143: #define w_retcode w_T.w_Retcode 144: #define w_stopval w_S.w_Stopval 145: #define w_stopsig w_S.w_Stopsig 146: 147: #define WSTOPPED _WSTOPPED 148: #endif /* __BSD_VISIBLE */ 149: 150: #ifndef _KERNEL 151: #include <sys/types.h> 152: 153: __BEGIN_DECLS 154: struct rusage; /* forward declaration */ 155: 156: pid_t wait(int *); 157: pid_t waitpid(pid_t, int *, int); 158: #if __BSD_VISIBLE 159: pid_t wait3(int *, int, struct rusage *); 160: pid_t wait4(pid_t, int *, int, struct rusage *); 161: #endif 162: __END_DECLS 163: #endif 164: 165: #endif /* !_SYS_WAIT_H_ */