1 /* NAME: 2 * wait.h - compensate for what vendors leave out 3 * 4 * AUTHOR: 5 * Simon J. Gerraty <sjg@crufty.net> 6 */ 7 /* 8 * RCSid: 9 * $Id: wait.h,v 1.7 2025/08/09 22:11:45 sjg Exp $ 10 * 11 * @(#)Copyright (c) 1994-2025, Simon J. Gerraty. 12 * 13 * SPDX-License-Identifier: BSD-2-Clause 14 * 15 * Please send copies of changes and bug-fixes to: 16 * sjg@crufty.net 17 */ 18 19 #include <sys/wait.h> 20 21 #ifdef sun386 22 # define UNION_WAIT 23 # define WEXITSTATUS(x) ((&x)->w_retcode) 24 # define WTERMSIG(x) ((&x)->w_termsig) 25 # define WSTOPSIG(x) ((&x)->w_stopsig) 26 # define HAVE_WAIT4 27 #endif 28 29 #ifndef WAIT_T 30 # ifdef UNION_WAIT 31 # define WAIT_T union wait 32 # define WAIT_STATUS(x) (x).w_status 33 # else 34 # define WAIT_T int 35 # define WAIT_STATUS(x) x 36 # endif 37 #endif 38 39 #ifndef WEXITSTATUS 40 # define WEXITSTATUS(_X) (((int)(_X)>>8)&0377) 41 #endif 42 #ifndef WSTOPPED 43 # define WSTOPPED 0177 44 #endif 45 #ifndef WSTOPSIG 46 # define WSTOPSIG(x) WSTOPPED 47 #endif 48 49 #ifdef UNION_WAIT 50 #ifndef WSET_STOPCODE 51 #define WSET_STOPCODE(x, sig) ((&x)->w_stopsig = (sig)) 52 #endif 53 #ifndef WSET_EXITCODE 54 #define WSET_EXITCODE(x, ret, sig) ((&x)->w_termsig = (sig), (&x)->w_retcode = (ret)) 55 #endif 56 #else 57 #ifndef WSET_STOPCODE 58 #define WSET_STOPCODE(x, sig) ((x) = ((sig) << 8) | 0177) 59 #endif 60 #ifndef WSET_EXITCODE 61 #define WSET_EXITCODE(x, ret, sig) ((x) = (ret << 8) | (sig)) 62 #endif 63 #endif 64 65 #ifndef HAVE_WAITPID 66 # ifdef HAVE_WAIT4 67 # define waitpid(pid, statusp, flags) wait4(pid, statusp, flags, (char *)0) 68 # else 69 # ifdef HAVE_WAIT3 70 # define waitpid(pid, statusp, flags) wait3(statusp, flags, (char *)0) 71 # endif 72 # endif 73 #endif 74