pkgsrc/shells/pdksh/files/ksh_wait.h
tnn 07f2d7c8b3 Merge assorted bugfixes to pdksh-5.2.14, taken as diff between
PDKSH-5_2_14 and NetBSD-current HEAD as of 2008-05-31.
- Fixes rare segfault seen on Solaris.
- add strlcpy and strlcat fallback implementations from libnbcompat
- regenerate configure (using autoconf-2.12, ugh)
2008-05-31 16:47:36 +00:00

52 lines
1.3 KiB
C

/* $NetBSD: ksh_wait.h,v 1.2 2008/05/31 16:47:37 tnn Exp $ */
/* Wrapper around the ugly sys/wait includes/ifdefs */
/* $NetBSD: ksh_wait.h,v 1.2 2008/05/31 16:47:37 tnn Exp $ */
#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 */