1236769Sobrien/* NAME: 2236769Sobrien * wait.h - compensate for what vendors leave out 3236769Sobrien * 4236769Sobrien * AUTHOR: 5236769Sobrien * Simon J. Gerraty <sjg@crufty.net> 6236769Sobrien */ 7236769Sobrien/* 8236769Sobrien * RCSid: 9236769Sobrien * $Id: wait.h,v 1.6 2002/11/26 07:53:06 sjg Exp $ 10236769Sobrien * 11236769Sobrien * @(#)Copyright (c) 1994, Simon J. Gerraty. 12236769Sobrien * 13236769Sobrien * This is free software. It comes with NO WARRANTY. 14236769Sobrien * Permission to use, modify and distribute this source code 15236769Sobrien * is granted subject to the following conditions. 16236769Sobrien * 1/ that the above copyright notice and this notice 17236769Sobrien * are preserved in all copies and that due credit be given 18236769Sobrien * to the author. 19236769Sobrien * 2/ that any changes to this code are clearly commented 20236769Sobrien * as such so that the author does not get blamed for bugs 21236769Sobrien * other than his own. 22236769Sobrien * 23236769Sobrien * Please send copies of changes and bug-fixes to: 24236769Sobrien * sjg@crufty.net 25236769Sobrien */ 26236769Sobrien 27236769Sobrien#include <sys/wait.h> 28236769Sobrien 29236769Sobrien#ifdef sun386 30236769Sobrien# define UNION_WAIT 31236769Sobrien# define WEXITSTATUS(x) ((&x)->w_retcode) 32236769Sobrien# define WTERMSIG(x) ((&x)->w_termsig) 33236769Sobrien# define WSTOPSIG(x) ((&x)->w_stopsig) 34236769Sobrien# define HAVE_WAIT4 35236769Sobrien#endif 36236769Sobrien 37236769Sobrien#ifndef WAIT_T 38236769Sobrien# ifdef UNION_WAIT 39236769Sobrien# define WAIT_T union wait 40236769Sobrien# define WAIT_STATUS(x) (x).w_status 41236769Sobrien# else 42236769Sobrien# define WAIT_T int 43236769Sobrien# define WAIT_STATUS(x) x 44236769Sobrien# endif 45236769Sobrien#endif 46236769Sobrien 47236769Sobrien#ifndef WEXITSTATUS 48236769Sobrien# define WEXITSTATUS(_X) (((int)(_X)>>8)&0377) 49236769Sobrien#endif 50236769Sobrien#ifndef WSTOPPED 51236769Sobrien# define WSTOPPED 0177 52236769Sobrien#endif 53236769Sobrien#ifndef WSTOPSIG 54236769Sobrien# define WSTOPSIG(x) WSTOPPED 55236769Sobrien#endif 56236769Sobrien 57236769Sobrien#ifdef UNION_WAIT 58236769Sobrien#ifndef WSET_STOPCODE 59236769Sobrien#define WSET_STOPCODE(x, sig) ((&x)->w_stopsig = (sig)) 60236769Sobrien#endif 61236769Sobrien#ifndef WSET_EXITCODE 62236769Sobrien#define WSET_EXITCODE(x, ret, sig) ((&x)->w_termsig = (sig), (&x)->w_retcode = (ret)) 63236769Sobrien#endif 64236769Sobrien#else 65236769Sobrien#ifndef WSET_STOPCODE 66236769Sobrien#define WSET_STOPCODE(x, sig) ((x) = ((sig) << 8) | 0177) 67236769Sobrien#endif 68236769Sobrien#ifndef WSET_EXITCODE 69236769Sobrien#define WSET_EXITCODE(x, ret, sig) ((x) = (ret << 8) | (sig)) 70236769Sobrien#endif 71236769Sobrien#endif 72236769Sobrien 73236769Sobrien#ifndef HAVE_WAITPID 74236769Sobrien# ifdef HAVE_WAIT4 75236769Sobrien# define waitpid(pid, statusp, flags) wait4(pid, statusp, flags, (char *)0) 76236769Sobrien# else 77236769Sobrien# ifdef HAVE_WAIT3 78236769Sobrien# define waitpid(pid, statusp, flags) wait3(statusp, flags, (char *)0) 79236769Sobrien# endif 80236769Sobrien# endif 81236769Sobrien#endif 82