tc.wait.h revision 100616
1100616Smp/* $Header: /src/pub/tcsh/tc.wait.h,v 3.13 2002/05/30 15:22:09 christos Exp $ */ 259243Sobrien/* 359243Sobrien * tc.wait.h: <sys/wait.h> for machines that don't have it or have it and 459243Sobrien * is incorrect. 559243Sobrien */ 659243Sobrien/*- 759243Sobrien * Copyright (c) 1980, 1991 The Regents of the University of California. 859243Sobrien * All rights reserved. 959243Sobrien * 1059243Sobrien * Redistribution and use in source and binary forms, with or without 1159243Sobrien * modification, are permitted provided that the following conditions 1259243Sobrien * are met: 1359243Sobrien * 1. Redistributions of source code must retain the above copyright 1459243Sobrien * notice, this list of conditions and the following disclaimer. 1559243Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1659243Sobrien * notice, this list of conditions and the following disclaimer in the 1759243Sobrien * documentation and/or other materials provided with the distribution. 18100616Smp * 3. Neither the name of the University nor the names of its contributors 1959243Sobrien * may be used to endorse or promote products derived from this software 2059243Sobrien * without specific prior written permission. 2159243Sobrien * 2259243Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2359243Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2459243Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2559243Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2659243Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2759243Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2859243Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2959243Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3059243Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3159243Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3259243Sobrien * SUCH DAMAGE. 3359243Sobrien */ 3459243Sobrien#ifndef _h_tc_wait 3559243Sobrien#define _h_tc_wait 3659243Sobrien 3759243Sobrien/* 3859243Sobrien * a little complicated #include <sys/wait.h>! :-( 3959243Sobrien * We try to use the system's wait.h when we can... 4059243Sobrien */ 4159243Sobrien 4259243Sobrien#if SYSVREL > 0 && !defined(linux) 4359243Sobrien# ifdef hpux 4459243Sobrien# ifndef __hpux 4559243Sobrien# define NEEDwait 4659243Sobrien# else 4759243Sobrien# ifndef POSIX 4859243Sobrien# define _BSD 4959243Sobrien# endif 5059243Sobrien# ifndef _CLASSIC_POSIX_TYPES 5159243Sobrien# define _CLASSIC_POSIX_TYPES 5259243Sobrien# endif 5359243Sobrien# include <sys/wait.h> /* 7.0 fixed it again */ 5459243Sobrien# endif /* __hpux */ 5559243Sobrien# else /* hpux */ 5659243Sobrien# if (defined(OREO) || defined(IRIS4D) || defined(POSIX)) && !defined(_VMS_POSIX) 5759243Sobrien# include <sys/wait.h> 5859243Sobrien# else /* OREO || IRIS4D || POSIX */ 5959243Sobrien# define NEEDwait 6059243Sobrien# endif /* OREO || IRIS4D || POSIX */ 6159243Sobrien# endif /* hpux */ 6259243Sobrien#else /* SYSVREL == 0 || linux */ 6359243Sobrien# ifdef _MINIX 6459243Sobrien# undef NEEDwait 6559243Sobrien# include "mi.wait.h" 6659243Sobrien# else 6769408Sache# ifndef WINNT_NATIVE 6859243Sobrien# include <sys/wait.h> 6969408Sache# endif /* WINNT_NATIVE */ 7059243Sobrien# endif /* _MINIX */ 7159243Sobrien#endif /* SYSVREL == 0 || linux */ 7259243Sobrien 7359243Sobrien#ifdef NEEDwait 7459243Sobrien/* 7559243Sobrien * This wait is for big-endians and little endians 7659243Sobrien */ 7759243Sobrienunion wait { 7859243Sobrien int w_status; 7959243Sobrien# ifdef _SEQUENT_ 8059243Sobrien struct { 8159243Sobrien unsigned short w_Termsig:7; 8259243Sobrien unsigned short w_Coredump:1; 8359243Sobrien unsigned short w_Retcode:8; 8459243Sobrien } w_T; 8559243Sobrien struct { 8659243Sobrien unsigned short w_Stopval:8; 8759243Sobrien unsigned short w_Stopsig:8; 8859243Sobrien } w_S; 8959243Sobrien}; 9059243Sobrien 9159243Sobrien# define w_termsig w_T.w_Termsig 9259243Sobrien# define w_coredump w_T.w_Coredump 9359243Sobrien# define w_retcode w_T.w_Retcode 9459243Sobrien# define w_stopval w_S.w_Stopval 9559243Sobrien# define w_stopsig w_S.w_Stopsig 9659243Sobrien# else /* _SEQUENT_ */ 97100616Smp# if defined(vax) || defined(__vax__) || defined(i386) || defined(_I386) || defined(__i386__) 9859243Sobrien union { 9959243Sobrien struct { 10059243Sobrien unsigned int w_Termsig:7; 10159243Sobrien unsigned int w_Coredump:1; 10259243Sobrien unsigned int w_Retcode:8; 10359243Sobrien unsigned int w_Dummy:16; 10459243Sobrien } w_T; 10559243Sobrien struct { 10659243Sobrien unsigned int w_Stopval:8; 10759243Sobrien unsigned int w_Stopsig:8; 10859243Sobrien unsigned int w_Dummy:16; 10959243Sobrien } w_S; 11059243Sobrien } w_P; 11159243Sobrien# else /* mc68000 || sparc || ??? */ 11259243Sobrien# if defined(_CRAY) || defined(ANY_OTHER_64BIT_MACHINE) 11359243Sobrien# define DUMMY_BITS 48 11459243Sobrien# else /* _CRAY */ 11559243Sobrien# define DUMMY_BITS 16 11659243Sobrien# endif /* _CRAY */ 11759243Sobrien union { 11859243Sobrien struct { 11959243Sobrien unsigned int w_Dummy:DUMMY_BITS; 12059243Sobrien unsigned int w_Retcode:8; 12159243Sobrien unsigned int w_Coredump:1; 12259243Sobrien unsigned int w_Termsig:7; 12359243Sobrien } w_T; 12459243Sobrien struct { 12559243Sobrien unsigned int w_Dummy:DUMMY_BITS; 12659243Sobrien unsigned int w_Stopsig:8; 12759243Sobrien unsigned int w_Stopval:8; 12859243Sobrien } w_S; 12959243Sobrien } w_P; 130100616Smp# endif /* vax || __vax__ || i386 || _I386 || __i386__ */ 13159243Sobrien}; 13259243Sobrien 13359243Sobrien# define w_termsig w_P.w_T.w_Termsig 13459243Sobrien# define w_coredump w_P.w_T.w_Coredump 13559243Sobrien# define w_retcode w_P.w_T.w_Retcode 13659243Sobrien# define w_stopval w_P.w_S.w_Stopval 13759243Sobrien# define w_stopsig w_P.w_S.w_Stopsig 13859243Sobrien# endif /* _SEQUENT_ */ 13959243Sobrien 14059243Sobrien 14159243Sobrien# ifndef WNOHANG 14259243Sobrien# define WNOHANG 1 /* dont hang in wait */ 14359243Sobrien# endif 14459243Sobrien 14559243Sobrien# ifndef WUNTRACED 14659243Sobrien# define WUNTRACED 2 /* tell about stopped, untraced children */ 14759243Sobrien# endif 14859243Sobrien 14959243Sobrien# define WSTOPPED 0177 15059243Sobrien# define WIFSTOPPED(x) ((x).w_stopval == WSTOPPED) 15159243Sobrien# define WIFSIGNALED(x) (((x).w_stopval != WSTOPPED) && ((x).w_termsig != 0)) 15259243Sobrien 15359243Sobrien#endif /* NEEDwait */ 15459243Sobrien 15559243Sobrien#endif /* _h_tc_wait */ 156