wait.h revision 267654
1181641Skmacy/* NAME:
2181641Skmacy *	wait.h - compensate for what vendors leave out
3181641Skmacy *
4183118Skmacy * AUTHOR:
5181641Skmacy *	Simon J. Gerraty <sjg@crufty.net>
6181641Skmacy */
7181641Skmacy/*
8181641Skmacy * RCSid:
9181641Skmacy *	$Id: wait.h,v 1.6 2002/11/26 07:53:06 sjg Exp $
10181641Skmacy *
11181641Skmacy *      @(#)Copyright (c) 1994, Simon J. Gerraty.
12181641Skmacy *
13181641Skmacy *      This is free software.  It comes with NO WARRANTY.
14181641Skmacy *      Permission to use, modify and distribute this source code
15181641Skmacy *      is granted subject to the following conditions.
16181641Skmacy *      1/ that the above copyright notice and this notice
17181641Skmacy *      are preserved in all copies and that due credit be given
18181641Skmacy *      to the author.
19181641Skmacy *      2/ that any changes to this code are clearly commented
20181641Skmacy *      as such so that the author does not get blamed for bugs
21181641Skmacy *      other than his own.
22181641Skmacy *
23181641Skmacy *      Please send copies of changes and bug-fixes to:
24181641Skmacy *      sjg@crufty.net
25181641Skmacy */
26181641Skmacy
27181641Skmacy#include <sys/wait.h>
28181641Skmacy
29181641Skmacy#ifdef sun386
30181641Skmacy# define UNION_WAIT
31181641Skmacy# define WEXITSTATUS(x) ((&x)->w_retcode)
32181641Skmacy# define WTERMSIG(x) ((&x)->w_termsig)
33181641Skmacy# define WSTOPSIG(x) ((&x)->w_stopsig)
34181641Skmacy# define HAVE_WAIT4
35181641Skmacy#endif
36181641Skmacy
37181641Skmacy#ifndef WAIT_T
38181641Skmacy# ifdef UNION_WAIT
39197693Skmacy#   define WAIT_T union wait
40185604Skmacy#   define WAIT_STATUS(x) (x).w_status
41181641Skmacy# else
42181641Skmacy#   define WAIT_T int
43185604Skmacy#   define WAIT_STATUS(x) x
44181641Skmacy# endif
45216944Scperciva#endif
46181641Skmacy
47241498Salc#ifndef WEXITSTATUS
48181641Skmacy# define WEXITSTATUS(_X)       (((int)(_X)>>8)&0377)
49271132Semaste#endif
50181641Skmacy#ifndef WSTOPPED
51255040Sgibbs# define WSTOPPED 0177
52181806Skmacy#endif
53181641Skmacy#ifndef WSTOPSIG
54181641Skmacy# define WSTOPSIG(x) WSTOPPED
55181641Skmacy#endif
56181641Skmacy
57181641Skmacy#ifdef UNION_WAIT
58181641Skmacy#ifndef WSET_STOPCODE
59181641Skmacy#define WSET_STOPCODE(x, sig) ((&x)->w_stopsig = (sig))
60181641Skmacy#endif
61181641Skmacy#ifndef WSET_EXITCODE
62181641Skmacy#define WSET_EXITCODE(x, ret, sig) ((&x)->w_termsig = (sig), (&x)->w_retcode = (ret))
63181641Skmacy#endif
64181641Skmacy#else
65181641Skmacy#ifndef WSET_STOPCODE
66186557Skmacy#define WSET_STOPCODE(x, sig) ((x) = ((sig) << 8) | 0177)
67181641Skmacy#endif
68181641Skmacy#ifndef WSET_EXITCODE
69181641Skmacy#define WSET_EXITCODE(x, ret, sig) ((x) = (ret << 8) | (sig))
70181641Skmacy#endif
71181641Skmacy#endif
72181641Skmacy
73181641Skmacy#ifndef HAVE_WAITPID
74181641Skmacy# ifdef HAVE_WAIT4
75181641Skmacy#   define waitpid(pid, statusp, flags)	 wait4(pid, statusp, flags, (char *)0)
76181641Skmacy# else
77181806Skmacy#   ifdef HAVE_WAIT3
78181747Skmacy#     define waitpid(pid, statusp, flags) wait3(statusp, flags, (char *)0)
79181747Skmacy#   endif
80181747Skmacy# endif
81181641Skmacy#endif
82181641Skmacy