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.6 2002/11/26 07:53:06 sjg Exp $ 10 * 11 * @(#)Copyright (c) 1994, Simon J. Gerraty. 12 * 13 * This is free software. It comes with NO WARRANTY. 14 * Permission to use, modify and distribute this source code 15 * is granted subject to the following conditions. 16 * 1/ that the above copyright notice and this notice 17 * are preserved in all copies and that due credit be given 18 * to the author. 19 * 2/ that any changes to this code are clearly commented 20 * as such so that the author does not get blamed for bugs 21 * other than his own. 22 * 23 * Please send copies of changes and bug-fixes to: 24 * sjg@crufty.net 25 */ 26 27 #include <sys/wait.h> 28 29 #ifdef sun386 30 # define UNION_WAIT 31 # define WEXITSTATUS(x) ((&x)->w_retcode) 32 # define WTERMSIG(x) ((&x)->w_termsig) 33 # define WSTOPSIG(x) ((&x)->w_stopsig) 34 # define HAVE_WAIT4 35 #endif 36 37 #ifndef WAIT_T 38 # ifdef UNION_WAIT 39 # define WAIT_T union wait 40 # define WAIT_STATUS(x) (x).w_status 41 # else 42 # define WAIT_T int 43 # define WAIT_STATUS(x) x 44 # endif 45 #endif 46 47 #ifndef WEXITSTATUS 48 # define WEXITSTATUS(_X) (((int)(_X)>>8)&0377) 49 #endif 50 #ifndef WSTOPPED 51 # define WSTOPPED 0177 52 #endif 53 #ifndef WSTOPSIG 54 # define WSTOPSIG(x) WSTOPPED 55 #endif 56 57 #ifdef UNION_WAIT 58 #ifndef WSET_STOPCODE 59 #define WSET_STOPCODE(x, sig) ((&x)->w_stopsig = (sig)) 60 #endif 61 #ifndef WSET_EXITCODE 62 #define WSET_EXITCODE(x, ret, sig) ((&x)->w_termsig = (sig), (&x)->w_retcode = (ret)) 63 #endif 64 #else 65 #ifndef WSET_STOPCODE 66 #define WSET_STOPCODE(x, sig) ((x) = ((sig) << 8) | 0177) 67 #endif 68 #ifndef WSET_EXITCODE 69 #define WSET_EXITCODE(x, ret, sig) ((x) = (ret << 8) | (sig)) 70 #endif 71 #endif 72 73 #ifndef HAVE_WAITPID 74 # ifdef HAVE_WAIT4 75 # define waitpid(pid, statusp, flags) wait4(pid, statusp, flags, (char *)0) 76 # else 77 # ifdef HAVE_WAIT3 78 # define waitpid(pid, statusp, flags) wait3(statusp, flags, (char *)0) 79 # endif 80 # endif 81 #endif 82