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 /* 23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 28 /* All Rights Reserved */ 29 30 /* 31 * Portions of this source code were derived from Berkeley 4.3 BSD 32 * under license from the Regents of the University of California. 33 */ 34 35 #ifndef _SYS_WAIT_H 36 #define _SYS_WAIT_H 37 38 #include <sys/isa_defs.h> 39 #include <sys/resource.h> 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 /* 46 * This wait.h is a combination of SunOS's wait.h and SysV wait.h 47 * The structure 'union wait' is taken from SunOS, while the 48 * rest of the #define's are from SysV. 49 */ 50 51 /* 52 * Structure of the information in the first word returned by both 53 * wait and wait3. If w_stopval==WSTOPPED, then the second structure 54 * describes the information returned, else the first. See WUNTRACED below. 55 */ 56 union wait { 57 int w_status; /* used in syscall */ 58 /* 59 * Terminated process status. 60 */ 61 struct { 62 #if defined(_BIT_FIELDS_LTOH) 63 unsigned short w_Termsig:7; /* termination signal */ 64 unsigned short w_Coredump:1; /* core dump indicator */ 65 unsigned short w_Retcode:8; /* exit code if w_termsig==0 */ 66 #else 67 unsigned short w_Fill1:16; /* high 16 bits unused */ 68 unsigned short w_Retcode:8; /* exit code if w_termsig==0 */ 69 unsigned short w_Coredump:1; /* core dump indicator */ 70 unsigned short w_Termsig:7; /* termination signal */ 71 #endif 72 } w_T; 73 /* 74 * Stopped process status. Returned 75 * only for traced children unless requested 76 * with the WUNTRACED option bit. 77 */ 78 struct { 79 #if defined(_BIT_FIELDS_LTOH) 80 unsigned short w_Stopval:8; /* == W_STOPPED if stopped */ 81 unsigned short w_Stopsig:8; /* signal that stopped us */ 82 #else 83 unsigned short w_Fill2:16; /* high 16 bits unused */ 84 unsigned short w_Stopsig:8; /* signal that stopped us */ 85 unsigned short w_Stopval:8; /* == W_STOPPED if stopped */ 86 #endif 87 } w_S; 88 }; 89 #define w_termsig w_T.w_Termsig 90 #define w_coredump w_T.w_Coredump 91 #define w_retcode w_T.w_Retcode 92 #define w_stopval w_S.w_Stopval 93 #define w_stopsig w_S.w_Stopsig 94 95 /* ----- begin SysV wait.h ----- */ 96 97 #include <sys/types.h> 98 #ifdef BUS_OBJERR /* Namespace conflict */ 99 #undef BUS_OBJERR 100 #endif 101 #include <sys/siginfo.h> 102 #include <sys/procset.h> 103 104 /* 105 * arguments to wait functions 106 */ 107 108 #define WEXITED 0001 /* wait for processes that have exite */ 109 #define WTRAPPED 0002 /* wait for processes stopped while tracing */ 110 #define N_WSTOPPED 0004 /* wait for processes stopped by signals */ 111 #define WCONTINUED 0010 /* wait for processes continued */ 112 113 #define WUNTRACED N_WSTOPPED /* for POSIX */ 114 115 #define WNOHANG 0100 /* non blocking form of wait */ 116 #define WNOWAIT 0200 /* non destructive form of wait */ 117 118 #define WOPTMASK (WEXITED|WTRAPPED|WSTOPPED|WCONTINUED|WNOHANG|WNOWAIT) 119 120 /* 121 * macros for stat return from wait functions 122 */ 123 124 #define WSTOPFLG 0177 125 #define WSTOPPED WSTOPFLG 126 /* This is for source compatibility w/ SunOS */ 127 #define WCONTFLG 0177777 128 #define WCOREFLG 0200 129 #define WSIGMASK 0177 130 131 #define WLOBYTE(stat) ((int)((stat)&0377)) 132 #define WHIBYTE(stat) ((int)(((stat)>>8)&0377)) 133 #define WWORD(stat) ((int)((stat))&0177777) 134 135 #define WIFEXITED(stat) (WLOBYTE(stat) == 0) 136 #define WIFSIGNALED(stat) (WLOBYTE(stat) > 0 && WHIBYTE(stat) == 0) 137 #define WIFSTOPPED(stat) (WLOBYTE(stat) == WSTOPFLG&&WHIBYTE(stat) != 0) 138 #define WIFCONTINUED(stat) (WWORD(stat) == WCONTFLG) 139 140 #define WEXITSTATUS(stat) WHIBYTE(stat) 141 #define WTERMSIG(stat) (WLOBYTE(stat)&WSIGMASK) 142 #define WSTOPSIG(stat) WHIBYTE(stat) 143 #define WCOREDUMP(stat) ((stat)&WCOREFLG) 144 145 146 147 #if !defined(_KERNEL) 148 #if defined(__STDC__) 149 150 extern pid_t wait(int *); 151 extern pid_t waitpid(pid_t, int *, int); 152 extern int waitid(idtype_t, id_t, siginfo_t *, int); 153 extern pid_t wait4(pid_t, int *, int, struct rusage *); 154 extern pid_t wait3(int *, int, struct rusage *); 155 156 #else 157 158 extern pid_t wait(); 159 extern pid_t waitpid(); 160 extern int waitid(); 161 162 #endif /* __STDC__ */ 163 #endif /* _KERNEL */ 164 165 #ifdef __cplusplus 166 } 167 #endif 168 169 #endif /* _SYS_WAIT_H */ 170