changelog for 0.9.1
[posh.git] / ksh_wait.h
blobc34c4549ad3640805c7b511b8fc00a4d54c03fe8
1 /* Wrapper around the ugly sys/wait includes/ifdefs */
2 /* $Id$ */
4 #ifdef HAVE_SYS_WAIT_H
5 # include <sys/wait.h>
6 #endif
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 */
19 #ifndef WIFCORED
20 # define WIFCORED(s) ((s) & 0x80)
21 #endif
22 #define WSTATUS(s) (s)
24 #ifndef WIFEXITED
25 # define WIFEXITED(s) (((s) & 0xff) == 0)
26 #endif
27 #ifndef WEXITSTATUS
28 # define WEXITSTATUS(s) (((s) >> 8) & 0xff)
29 #endif
30 #ifndef WIFSIGNALED
31 # define WIFSIGNALED(s) (((s) & 0xff) != 0 && ((s) & 0xff) != 0x7f)
32 #endif
33 #ifndef WTERMSIG
34 # define WTERMSIG(s) ((s) & 0x7f)
35 #endif
36 #ifndef WIFSTOPPED
37 # define WIFSTOPPED(s) (((s) & 0xff) == 0x7f)
38 #endif
39 #ifndef WSTOPSIG
40 # define WSTOPSIG(s) (((s) >> 8) & 0xff)
41 #endif
43 #if !defined(HAVE_WAITPID) && defined(HAVE_WAIT3)
44 /* always used with p == -1 */
45 # define ksh_waitpid(p, s, o) wait3((s), (o), (struct rusage *) 0)
46 #else /* !HAVE_WAITPID && HAVE_WAIT3 */
47 # define ksh_waitpid(p, s, o) waitpid((p), (s), (o))
48 #endif /* !HAVE_WAITPID && HAVE_WAIT3 */