summaryrefslogtreecommitdiff
path: root/sys/src/ape/cmd/pdksh/ksh_wait.h
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
commite5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch)
treed8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/ape/cmd/pdksh/ksh_wait.h
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/ape/cmd/pdksh/ksh_wait.h')
-rwxr-xr-xsys/src/ape/cmd/pdksh/ksh_wait.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/sys/src/ape/cmd/pdksh/ksh_wait.h b/sys/src/ape/cmd/pdksh/ksh_wait.h
new file mode 100755
index 000000000..7a4165279
--- /dev/null
+++ b/sys/src/ape/cmd/pdksh/ksh_wait.h
@@ -0,0 +1,50 @@
+/* Wrapper around the ugly sys/wait includes/ifdefs */
+/* $Id$ */
+
+#ifdef HAVE_SYS_WAIT_H
+# include <sys/wait.h>
+#endif
+
+#ifndef POSIX_SYS_WAIT
+/* Get rid of system macros (which probably use union wait) */
+# undef WIFCORED
+# undef WIFEXITED
+# undef WEXITSTATUS
+# undef WIFSIGNALED
+# undef WTERMSIG
+# undef WIFSTOPPED
+# undef WSTOPSIG
+#endif /* POSIX_SYS_WAIT */
+
+typedef int WAIT_T;
+
+#ifndef WIFCORED
+# define WIFCORED(s) ((s) & 0x80)
+#endif
+#define WSTATUS(s) (s)
+
+#ifndef WIFEXITED
+# define WIFEXITED(s) (((s) & 0xff) == 0)
+#endif
+#ifndef WEXITSTATUS
+# define WEXITSTATUS(s) (((s) >> 8) & 0xff)
+#endif
+#ifndef WIFSIGNALED
+# define WIFSIGNALED(s) (((s) & 0xff) != 0 && ((s) & 0xff) != 0x7f)
+#endif
+#ifndef WTERMSIG
+# define WTERMSIG(s) ((s) & 0x7f)
+#endif
+#ifndef WIFSTOPPED
+# define WIFSTOPPED(s) (((s) & 0xff) == 0x7f)
+#endif
+#ifndef WSTOPSIG
+# define WSTOPSIG(s) (((s) >> 8) & 0xff)
+#endif
+
+#if !defined(HAVE_WAITPID) && defined(HAVE_WAIT3)
+ /* always used with p == -1 */
+# define ksh_waitpid(p, s, o) wait3((s), (o), (struct rusage *) 0)
+#else /* !HAVE_WAITPID && HAVE_WAIT3 */
+# define ksh_waitpid(p, s, o) waitpid((p), (s), (o))
+#endif /* !HAVE_WAITPID && HAVE_WAIT3 */