1/* unionwait.h -- definitions for using a `union wait' on systems without 2 one. */ 3 4/* Copyright (C) 1996 Free Software Foundation, Inc. 5 6 This file is part of GNU Bash, the Bourne Again SHell. 7 8 Bash is free software; you can redistribute it and/or modify it under 9 the terms of the GNU General Public License as published by the Free 10 Software Foundation; either version 2, or (at your option) any later 11 version. 12 13 Bash is distributed in the hope that it will be useful, but WITHOUT ANY 14 WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 for more details. 17 18 You should have received a copy of the GNU General Public License along 19 with Bash; see the file COPYING. If not, write to the Free Software 20 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ 21 22#ifndef _UNIONWAIT_H 23#define _UNIONWAIT_H 24 25#if !defined (WORDS_BIGENDIAN) 26union wait 27 { 28 int w_status; /* used in syscall */ 29 30 /* Terminated process status. */ 31 struct 32 { 33 unsigned short 34 w_Termsig : 7, /* termination signal */ 35 w_Coredump : 1, /* core dump indicator */ 36 w_Retcode : 8, /* exit code if w_termsig==0 */ 37 w_Fill1 : 16; /* high 16 bits unused */ 38 } w_T; 39 40 /* Stopped process status. Returned 41 only for traced children unless requested 42 with the WUNTRACED option bit. */ 43 struct 44 { 45 unsigned short 46 w_Stopval : 8, /* == W_STOPPED if stopped */ 47 w_Stopsig : 8, /* actually zero on XENIX */ 48 w_Fill2 : 16; /* high 16 bits unused */ 49 } w_S; 50 }; 51 52#else /* WORDS_BIGENDIAN */ 53 54/* This is for big-endian machines like the IBM RT, HP 9000, or Sun-3 */ 55 56union wait 57 { 58 int w_status; /* used in syscall */ 59 60 /* Terminated process status. */ 61 struct 62 { 63 unsigned short w_Fill1 : 16; /* high 16 bits unused */ 64 unsigned w_Retcode : 8; /* exit code if w_termsig==0 */ 65 unsigned w_Coredump : 1; /* core dump indicator */ 66 unsigned w_Termsig : 7; /* termination signal */ 67 } w_T; 68 69 /* Stopped process status. Returned 70 only for traced children unless requested 71 with the WUNTRACED option bit. */ 72 struct 73 { 74 unsigned short w_Fill2 : 16; /* high 16 bits unused */ 75 unsigned w_Stopsig : 8; /* signal that stopped us */ 76 unsigned w_Stopval : 8; /* == W_STOPPED if stopped */ 77 } w_S; 78 }; 79 80#endif /* WORDS_BIGENDIAN */ 81 82#define w_termsig w_T.w_Termsig 83#define w_coredump w_T.w_Coredump 84#define w_retcode w_T.w_Retcode 85#define w_stopval w_S.w_Stopval 86#define w_stopsig w_S.w_Stopsig 87 88#define WSTOPPED 0177 89#define WIFSTOPPED(x) ((x).w_stopval == WSTOPPED) 90#define WIFEXITED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig == 0) 91#define WIFSIGNALED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig != 0) 92 93#define WTERMSIG(x) ((x).w_termsig) 94#define WSTOPSIG(x) ((x).w_stopsig) 95#define WEXITSTATUS(x) ((x).w_retcode) 96#define WIFCORED(x) ((x).w_coredump) 97 98#endif /* _UNIONWAIT_H */ 99