1 /* 2 * tc.wait.h: <sys/wait.h> for machines that don't have it or have it and 3 * is incorrect. 4 */ 5 /*- 6 * Copyright (c) 1980, 1991 The Regents of the University of California. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 #ifndef _h_tc_wait 34 #define _h_tc_wait 35 36 /* 37 * a little complicated #include <sys/wait.h>! :-( 38 * We try to use the system's wait.h when we can... 39 */ 40 41 #if SYSVREL > 0 && !defined(__linux__) && !defined(__GNU__) && !defined(__GLIBC__) 42 # ifdef hpux 43 # ifndef __hpux 44 # define NEEDwait 45 # else 46 # ifndef POSIX 47 # define _BSD 48 # endif 49 # ifndef _CLASSIC_POSIX_TYPES 50 # define _CLASSIC_POSIX_TYPES 51 # endif 52 # include <sys/wait.h> /* 7.0 fixed it again */ 53 # endif /* __hpux */ 54 # else /* hpux */ 55 # if (defined(OREO) || defined(IRIS4D) || defined(POSIX)) && !defined(_VMS_POSIX) 56 # include <sys/wait.h> 57 # else /* OREO || IRIS4D || POSIX */ 58 # define NEEDwait 59 # endif /* OREO || IRIS4D || POSIX */ 60 # endif /* hpux */ 61 #else /* SYSVREL == 0 || glibc */ 62 # ifdef _MINIX 63 # undef NEEDwait 64 # include "mi.wait.h" 65 # else 66 # ifndef WINNT_NATIVE 67 # include <sys/wait.h> 68 # endif /* WINNT_NATIVE */ 69 # endif /* _MINIX */ 70 #endif /* SYSVREL == 0 || glibc */ 71 72 #ifdef NEEDwait 73 /* 74 * This wait is for big-endians and little endians 75 */ 76 union wait { 77 int w_status; 78 # ifdef _SEQUENT_ 79 struct { 80 unsigned short w_Termsig:7; 81 unsigned short w_Coredump:1; 82 unsigned short w_Retcode:8; 83 } w_T; 84 struct { 85 unsigned short w_Stopval:8; 86 unsigned short w_Stopsig:8; 87 } w_S; 88 }; 89 90 # define w_termsig w_T.w_Termsig 91 # define w_coredump w_T.w_Coredump 92 # define w_retcode w_T.w_Retcode 93 # define w_stopval w_S.w_Stopval 94 # define w_stopsig w_S.w_Stopsig 95 # else /* _SEQUENT_ */ 96 # if defined(vax) || defined(__vax__) || defined(i386) || defined(_I386) || defined(__i386__) 97 union { 98 struct { 99 unsigned int w_Termsig:7; 100 unsigned int w_Coredump:1; 101 unsigned int w_Retcode:8; 102 unsigned int w_Dummy:16; 103 } w_T; 104 struct { 105 unsigned int w_Stopval:8; 106 unsigned int w_Stopsig:8; 107 unsigned int w_Dummy:16; 108 } w_S; 109 } w_P; 110 # else /* mc68000 || sparc || ??? */ 111 # if defined(_CRAY) || defined(ANY_OTHER_64BIT_MACHINE) 112 # define DUMMY_BITS 48 113 # else /* _CRAY */ 114 # define DUMMY_BITS 16 115 # endif /* _CRAY */ 116 union { 117 struct { 118 unsigned int w_Dummy:DUMMY_BITS; 119 unsigned int w_Retcode:8; 120 unsigned int w_Coredump:1; 121 unsigned int w_Termsig:7; 122 } w_T; 123 struct { 124 unsigned int w_Dummy:DUMMY_BITS; 125 unsigned int w_Stopsig:8; 126 unsigned int w_Stopval:8; 127 } w_S; 128 } w_P; 129 # endif /* vax || __vax__ || i386 || _I386 || __i386__ */ 130 }; 131 132 # define w_termsig w_P.w_T.w_Termsig 133 # define w_coredump w_P.w_T.w_Coredump 134 # define w_retcode w_P.w_T.w_Retcode 135 # define w_stopval w_P.w_S.w_Stopval 136 # define w_stopsig w_P.w_S.w_Stopsig 137 # endif /* _SEQUENT_ */ 138 139 140 # ifndef WNOHANG 141 # define WNOHANG 1 /* dont hang in wait */ 142 # endif 143 144 # ifndef WUNTRACED 145 # define WUNTRACED 2 /* tell about stopped, untraced children */ 146 # endif 147 148 # define WSTOPPED 0177 149 # define WIFSTOPPED(x) ((x).w_stopval == WSTOPPED) 150 # define WIFSIGNALED(x) (((x).w_stopval != WSTOPPED) && ((x).w_termsig != 0)) 151 152 #endif /* NEEDwait */ 153 154 #endif /* _h_tc_wait */ 155