1 /* Wrapper around the ugly sys/wait includes/ifdefs */ 2 /* $Id$ */ 3 4 #ifdef HAVE_SYS_WAIT_H 5 # include <sys/wait.h> 6 #endif 7 8 #ifndef POSIX_SYS_WAIT 9 /* Get rid of system macros (which probably use union wait) */ 10 # undef WIFCORED 11 # undef WIFEXITED 12 # undef WEXITSTATUS 13 # undef WIFSIGNALED 14 # undef WTERMSIG 15 # undef WIFSTOPPED 16 # undef WSTOPSIG 17 #endif /* POSIX_SYS_WAIT */ 18 19 typedef int WAIT_T; 20 21 #ifndef WIFCORED 22 # define WIFCORED(s) ((s) & 0x80) 23 #endif 24 #define WSTATUS(s) (s) 25 26 #ifndef WIFEXITED 27 # define WIFEXITED(s) (((s) & 0xff) == 0) 28 #endif 29 #ifndef WEXITSTATUS 30 # define WEXITSTATUS(s) (((s) >> 8) & 0xff) 31 #endif 32 #ifndef WIFSIGNALED 33 # define WIFSIGNALED(s) (((s) & 0xff) != 0 && ((s) & 0xff) != 0x7f) 34 #endif 35 #ifndef WTERMSIG 36 # define WTERMSIG(s) ((s) & 0x7f) 37 #endif 38 #ifndef WIFSTOPPED 39 # define WIFSTOPPED(s) (((s) & 0xff) == 0x7f) 40 #endif 41 #ifndef WSTOPSIG 42 # define WSTOPSIG(s) (((s) >> 8) & 0xff) 43 #endif 44 45 #if !defined(HAVE_WAITPID) && defined(HAVE_WAIT3) 46 /* always used with p == -1 */ 47 # define ksh_waitpid(p, s, o) wait3((s), (o), (struct rusage *) 0) 48 #else /* !HAVE_WAITPID && HAVE_WAIT3 */ 49 # define ksh_waitpid(p, s, o) waitpid((p), (s), (o)) 50 #endif /* !HAVE_WAITPID && HAVE_WAIT3 */ 51