tc.wait.h revision 59243
159243Sobrien/* $Header: /src/pub/tcsh/tc.wait.h,v 3.10 1997/10/27 22:44:39 christos Exp $ */
259243Sobrien/*
359243Sobrien * tc.wait.h: <sys/wait.h> for machines that don't have it or have it and
459243Sobrien *	      is incorrect.
559243Sobrien */
659243Sobrien/*-
759243Sobrien * Copyright (c) 1980, 1991 The Regents of the University of California.
859243Sobrien * All rights reserved.
959243Sobrien *
1059243Sobrien * Redistribution and use in source and binary forms, with or without
1159243Sobrien * modification, are permitted provided that the following conditions
1259243Sobrien * are met:
1359243Sobrien * 1. Redistributions of source code must retain the above copyright
1459243Sobrien *    notice, this list of conditions and the following disclaimer.
1559243Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1659243Sobrien *    notice, this list of conditions and the following disclaimer in the
1759243Sobrien *    documentation and/or other materials provided with the distribution.
1859243Sobrien * 3. All advertising materials mentioning features or use of this software
1959243Sobrien *    must display the following acknowledgement:
2059243Sobrien *	This product includes software developed by the University of
2159243Sobrien *	California, Berkeley and its contributors.
2259243Sobrien * 4. Neither the name of the University nor the names of its contributors
2359243Sobrien *    may be used to endorse or promote products derived from this software
2459243Sobrien *    without specific prior written permission.
2559243Sobrien *
2659243Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2759243Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2859243Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2959243Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3059243Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3159243Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3259243Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3359243Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3459243Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3559243Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3659243Sobrien * SUCH DAMAGE.
3759243Sobrien */
3859243Sobrien#ifndef _h_tc_wait
3959243Sobrien#define _h_tc_wait
4059243Sobrien
4159243Sobrien/*
4259243Sobrien * a little complicated #include <sys/wait.h>! :-(
4359243Sobrien * We try to use the system's wait.h when we can...
4459243Sobrien */
4559243Sobrien
4659243Sobrien#if SYSVREL > 0 && !defined(linux)
4759243Sobrien# ifdef hpux
4859243Sobrien#  ifndef __hpux
4959243Sobrien#   define NEEDwait
5059243Sobrien#  else
5159243Sobrien#   ifndef POSIX
5259243Sobrien#    define _BSD
5359243Sobrien#   endif
5459243Sobrien#   ifndef _CLASSIC_POSIX_TYPES
5559243Sobrien#    define _CLASSIC_POSIX_TYPES
5659243Sobrien#   endif
5759243Sobrien#   include <sys/wait.h> /* 7.0 fixed it again */
5859243Sobrien#  endif /* __hpux */
5959243Sobrien# else /* hpux */
6059243Sobrien#  if (defined(OREO) || defined(IRIS4D) || defined(POSIX)) && !defined(_VMS_POSIX)
6159243Sobrien#   include <sys/wait.h>
6259243Sobrien#  else	/* OREO || IRIS4D || POSIX */
6359243Sobrien#   define NEEDwait
6459243Sobrien#  endif /* OREO || IRIS4D || POSIX */
6559243Sobrien# endif	/* hpux */
6659243Sobrien#else /* SYSVREL == 0 || linux */
6759243Sobrien# ifdef _MINIX
6859243Sobrien#  undef NEEDwait
6959243Sobrien#  include "mi.wait.h"
7059243Sobrien# else
7159243Sobrien#  ifndef WINNT
7259243Sobrien#   include <sys/wait.h>
7359243Sobrien#  endif /* WINNT */
7459243Sobrien# endif /* _MINIX */
7559243Sobrien#endif /* SYSVREL == 0 || linux */
7659243Sobrien
7759243Sobrien#ifdef NEEDwait
7859243Sobrien/*
7959243Sobrien *	This wait is for big-endians and little endians
8059243Sobrien */
8159243Sobrienunion wait {
8259243Sobrien    int     w_status;
8359243Sobrien# ifdef _SEQUENT_
8459243Sobrien    struct {
8559243Sobrien	unsigned short w_Termsig:7;
8659243Sobrien	unsigned short w_Coredump:1;
8759243Sobrien	unsigned short w_Retcode:8;
8859243Sobrien    }       w_T;
8959243Sobrien    struct {
9059243Sobrien	unsigned short w_Stopval:8;
9159243Sobrien	unsigned short w_Stopsig:8;
9259243Sobrien    }       w_S;
9359243Sobrien};
9459243Sobrien
9559243Sobrien#  define w_termsig     w_T.w_Termsig
9659243Sobrien#  define w_coredump    w_T.w_Coredump
9759243Sobrien#  define w_retcode     w_T.w_Retcode
9859243Sobrien#  define w_stopval     w_S.w_Stopval
9959243Sobrien#  define w_stopsig     w_S.w_Stopsig
10059243Sobrien# else /* _SEQUENT_ */
10159243Sobrien#  if defined(vax) || defined(i386) || defined(_I386)
10259243Sobrien    union {
10359243Sobrien	struct {
10459243Sobrien	    unsigned int w_Termsig:7;
10559243Sobrien	    unsigned int w_Coredump:1;
10659243Sobrien	    unsigned int w_Retcode:8;
10759243Sobrien	    unsigned int w_Dummy:16;
10859243Sobrien	}       w_T;
10959243Sobrien	struct {
11059243Sobrien	    unsigned int w_Stopval:8;
11159243Sobrien	    unsigned int w_Stopsig:8;
11259243Sobrien	    unsigned int w_Dummy:16;
11359243Sobrien	}       w_S;
11459243Sobrien    }       w_P;
11559243Sobrien#  else /* mc68000 || sparc || ??? */
11659243Sobrien#    if defined(_CRAY) || defined(ANY_OTHER_64BIT_MACHINE)
11759243Sobrien#      define DUMMY_BITS	48
11859243Sobrien#    else /* _CRAY */
11959243Sobrien#      define DUMMY_BITS	16
12059243Sobrien#    endif /* _CRAY */
12159243Sobrien    union {
12259243Sobrien	struct {
12359243Sobrien	    unsigned int w_Dummy:DUMMY_BITS;
12459243Sobrien	    unsigned int w_Retcode:8;
12559243Sobrien	    unsigned int w_Coredump:1;
12659243Sobrien	    unsigned int w_Termsig:7;
12759243Sobrien	}       w_T;
12859243Sobrien	struct {
12959243Sobrien	    unsigned int w_Dummy:DUMMY_BITS;
13059243Sobrien	    unsigned int w_Stopsig:8;
13159243Sobrien	    unsigned int w_Stopval:8;
13259243Sobrien	}       w_S;
13359243Sobrien    }       w_P;
13459243Sobrien#  endif /* vax || i386 || _I386 */
13559243Sobrien};
13659243Sobrien
13759243Sobrien#  define w_termsig	w_P.w_T.w_Termsig
13859243Sobrien#  define w_coredump	w_P.w_T.w_Coredump
13959243Sobrien#  define w_retcode	w_P.w_T.w_Retcode
14059243Sobrien#  define w_stopval	w_P.w_S.w_Stopval
14159243Sobrien#  define w_stopsig	w_P.w_S.w_Stopsig
14259243Sobrien# endif /* _SEQUENT_ */
14359243Sobrien
14459243Sobrien
14559243Sobrien# ifndef WNOHANG
14659243Sobrien#  define WNOHANG	1	/* dont hang in wait */
14759243Sobrien# endif
14859243Sobrien
14959243Sobrien# ifndef WUNTRACED
15059243Sobrien#  define WUNTRACED	2	/* tell about stopped, untraced children */
15159243Sobrien# endif
15259243Sobrien
15359243Sobrien# define WSTOPPED 0177
15459243Sobrien# define WIFSTOPPED(x)	((x).w_stopval == WSTOPPED)
15559243Sobrien# define WIFSIGNALED(x)	(((x).w_stopval != WSTOPPED) && ((x).w_termsig != 0))
15659243Sobrien
15759243Sobrien#endif /* NEEDwait */
15859243Sobrien
15959243Sobrien#endif /* _h_tc_wait */
160