tc.wait.h revision 145479
1336819Sdim/* $Header: /src/pub/tcsh/tc.wait.h,v 3.14 2004/12/25 21:15:08 christos Exp $ */ 2336819Sdim/* 3353358Sdim * tc.wait.h: <sys/wait.h> for machines that don't have it or have it and 4353358Sdim * is incorrect. 5353358Sdim */ 6336819Sdim/*- 7336819Sdim * Copyright (c) 1980, 1991 The Regents of the University of California. 8336819Sdim * All rights reserved. 9336819Sdim * 10336819Sdim * Redistribution and use in source and binary forms, with or without 11336819Sdim * modification, are permitted provided that the following conditions 12336819Sdim * are met: 13336819Sdim * 1. Redistributions of source code must retain the above copyright 14336819Sdim * notice, this list of conditions and the following disclaimer. 15336819Sdim * 2. Redistributions in binary form must reproduce the above copyright 16336819Sdim * notice, this list of conditions and the following disclaimer in the 17336819Sdim * documentation and/or other materials provided with the distribution. 18336819Sdim * 3. Neither the name of the University nor the names of its contributors 19336819Sdim * may be used to endorse or promote products derived from this software 20336819Sdim * without specific prior written permission. 21336819Sdim * 22336819Sdim * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23336819Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24336819Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25336819Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26336819Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27336819Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28336819Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29336819Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30336819Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31336819Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32336819Sdim * SUCH DAMAGE. 33336819Sdim */ 34336819Sdim#ifndef _h_tc_wait 35336819Sdim#define _h_tc_wait 36336819Sdim 37336819Sdim/* 38336819Sdim * a little complicated #include <sys/wait.h>! :-( 39336819Sdim * We try to use the system's wait.h when we can... 40336819Sdim */ 41336819Sdim 42336819Sdim#if SYSVREL > 0 && !defined(linux) && !defined(__GNU__) && !defined(__GLIBC__) 43336819Sdim# ifdef hpux 44336819Sdim# ifndef __hpux 45336819Sdim# define NEEDwait 46336819Sdim# else 47336819Sdim# ifndef POSIX 48336819Sdim# define _BSD 49336819Sdim# endif 50336819Sdim# ifndef _CLASSIC_POSIX_TYPES 51336819Sdim# define _CLASSIC_POSIX_TYPES 52336819Sdim# endif 53336819Sdim# include <sys/wait.h> /* 7.0 fixed it again */ 54336819Sdim# endif /* __hpux */ 55336819Sdim# else /* hpux */ 56336819Sdim# if (defined(OREO) || defined(IRIS4D) || defined(POSIX)) && !defined(_VMS_POSIX) 57336819Sdim# include <sys/wait.h> 58336819Sdim# else /* OREO || IRIS4D || POSIX */ 59336819Sdim# define NEEDwait 60336819Sdim# endif /* OREO || IRIS4D || POSIX */ 61336819Sdim# endif /* hpux */ 62336819Sdim#else /* SYSVREL == 0 || glibc */ 63336819Sdim# ifdef _MINIX 64336819Sdim# undef NEEDwait 65336819Sdim# include "mi.wait.h" 66336819Sdim# else 67336819Sdim# ifndef WINNT_NATIVE 68336819Sdim# include <sys/wait.h> 69344779Sdim# endif /* WINNT_NATIVE */ 70344779Sdim# endif /* _MINIX */ 71336819Sdim#endif /* SYSVREL == 0 || glibc */ 72344779Sdim 73344779Sdim#ifdef NEEDwait 74336819Sdim/* 75336819Sdim * This wait is for big-endians and little endians 76336819Sdim */ 77336819Sdimunion wait { 78336819Sdim int w_status; 79344779Sdim# ifdef _SEQUENT_ 80344779Sdim struct { 81344779Sdim unsigned short w_Termsig:7; 82344779Sdim unsigned short w_Coredump:1; 83344779Sdim unsigned short w_Retcode:8; 84336819Sdim } w_T; 85344779Sdim struct { 86344779Sdim unsigned short w_Stopval:8; 87344779Sdim unsigned short w_Stopsig:8; 88344779Sdim } w_S; 89344779Sdim}; 90344779Sdim 91344779Sdim# define w_termsig w_T.w_Termsig 92344779Sdim# define w_coredump w_T.w_Coredump 93344779Sdim# define w_retcode w_T.w_Retcode 94336819Sdim# define w_stopval w_S.w_Stopval 95336819Sdim# define w_stopsig w_S.w_Stopsig 96336819Sdim# else /* _SEQUENT_ */ 97336819Sdim# if defined(vax) || defined(__vax__) || defined(i386) || defined(_I386) || defined(__i386__) 98336819Sdim union { 99336819Sdim struct { 100336819Sdim unsigned int w_Termsig:7; 101336819Sdim unsigned int w_Coredump:1; 102336819Sdim unsigned int w_Retcode:8; 103336819Sdim unsigned int w_Dummy:16; 104336819Sdim } w_T; 105336819Sdim struct { 106336819Sdim unsigned int w_Stopval:8; 107336819Sdim unsigned int w_Stopsig:8; 108336819Sdim unsigned int w_Dummy:16; 109336819Sdim } w_S; 110336819Sdim } w_P; 111336819Sdim# else /* mc68000 || sparc || ??? */ 112336819Sdim# if defined(_CRAY) || defined(ANY_OTHER_64BIT_MACHINE) 113336819Sdim# define DUMMY_BITS 48 114336819Sdim# else /* _CRAY */ 115336819Sdim# define DUMMY_BITS 16 116336819Sdim# endif /* _CRAY */ 117336819Sdim union { 118336819Sdim struct { 119336819Sdim unsigned int w_Dummy:DUMMY_BITS; 120336819Sdim unsigned int w_Retcode:8; 121336819Sdim unsigned int w_Coredump:1; 122336819Sdim unsigned int w_Termsig:7; 123336819Sdim } w_T; 124336819Sdim struct { 125336819Sdim unsigned int w_Dummy:DUMMY_BITS; 126336819Sdim unsigned int w_Stopsig:8; 127336819Sdim unsigned int w_Stopval:8; 128336819Sdim } w_S; 129336819Sdim } w_P; 130336819Sdim# endif /* vax || __vax__ || i386 || _I386 || __i386__ */ 131336819Sdim}; 132336819Sdim 133336819Sdim# define w_termsig w_P.w_T.w_Termsig 134336819Sdim# define w_coredump w_P.w_T.w_Coredump 135336819Sdim# define w_retcode w_P.w_T.w_Retcode 136336819Sdim# define w_stopval w_P.w_S.w_Stopval 137336819Sdim# define w_stopsig w_P.w_S.w_Stopsig 138336819Sdim# endif /* _SEQUENT_ */ 139336819Sdim 140336819Sdim 141336819Sdim# ifndef WNOHANG 142336819Sdim# define WNOHANG 1 /* dont hang in wait */ 143336819Sdim# endif 144336819Sdim 145336819Sdim# ifndef WUNTRACED 146336819Sdim# define WUNTRACED 2 /* tell about stopped, untraced children */ 147336819Sdim# endif 148336819Sdim 149336819Sdim# define WSTOPPED 0177 150336819Sdim# define WIFSTOPPED(x) ((x).w_stopval == WSTOPPED) 151336819Sdim# define WIFSIGNALED(x) (((x).w_stopval != WSTOPPED) && ((x).w_termsig != 0)) 152336819Sdim 153336819Sdim#endif /* NEEDwait */ 154336819Sdim 155336819Sdim#endif /* _h_tc_wait */ 156336819Sdim