Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 1 | /* unionwait.h -- definitions for using a `union wait' on systems without |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 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 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 8 | Bash is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 3 of the License, or |
| 11 | (at your option) any later version. |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 12 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 13 | Bash is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 17 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 18 | You should have received a copy of the GNU General Public License |
| 19 | along with Bash. If not, see <http://www.gnu.org/licenses/>. |
| 20 | */ |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 21 | |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 22 | #ifndef _UNIONWAIT_H |
| 23 | #define _UNIONWAIT_H |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 24 | |
| 25 | #if !defined (WORDS_BIGENDIAN) |
| 26 | union 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 | |
| 56 | union 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 | |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 98 | #endif /* _UNIONWAIT_H */ |