summaryrefslogtreecommitdiffstats
path: root/contrib/tcsh/tc.wait.h
blob: fc55e3f13430c3c98ba6fbfc6863c284aba47dee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/* $Header: /src/pub/tcsh/tc.wait.h,v 3.13 2002/05/30 15:22:09 christos Exp $ */
/*
 * tc.wait.h: <sys/wait.h> for machines that don't have it or have it and
 *	      is incorrect.
 */
/*-
 * Copyright (c) 1980, 1991 The Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */
#ifndef _h_tc_wait
#define _h_tc_wait

/*
 * a little complicated #include <sys/wait.h>! :-(
 * We try to use the system's wait.h when we can...
 */

#if SYSVREL > 0 && !defined(linux)
# ifdef hpux
#  ifndef __hpux
#   define NEEDwait
#  else
#   ifndef POSIX
#    define _BSD
#   endif
#   ifndef _CLASSIC_POSIX_TYPES
#    define _CLASSIC_POSIX_TYPES
#   endif
#   include <sys/wait.h> /* 7.0 fixed it again */
#  endif /* __hpux */
# else /* hpux */
#  if (defined(OREO) || defined(IRIS4D) || defined(POSIX)) && !defined(_VMS_POSIX)
#   include <sys/wait.h>
#  else	/* OREO || IRIS4D || POSIX */
#   define NEEDwait
#  endif /* OREO || IRIS4D || POSIX */
# endif	/* hpux */
#else /* SYSVREL == 0 || linux */
# ifdef _MINIX
#  undef NEEDwait
#  include "mi.wait.h"
# else
#  ifndef WINNT_NATIVE
#   include <sys/wait.h>
#  endif /* WINNT_NATIVE */
# endif /* _MINIX */
#endif /* SYSVREL == 0 || linux */

#ifdef NEEDwait
/*
 *	This wait is for big-endians and little endians
 */
union wait {
    int     w_status;
# ifdef _SEQUENT_
    struct {
	unsigned short w_Termsig:7;
	unsigned short w_Coredump:1;
	unsigned short w_Retcode:8;
    }       w_T;
    struct {
	unsigned short w_Stopval:8;
	unsigned short w_Stopsig:8;
    }       w_S;
};

#  define w_termsig     w_T.w_Termsig
#  define w_coredump    w_T.w_Coredump
#  define w_retcode     w_T.w_Retcode
#  define w_stopval     w_S.w_Stopval
#  define w_stopsig     w_S.w_Stopsig
# else /* _SEQUENT_ */
#  if defined(vax) || defined(__vax__) || defined(i386) || defined(_I386) || defined(__i386__)
    union {
	struct {
	    unsigned int w_Termsig:7;
	    unsigned int w_Coredump:1;
	    unsigned int w_Retcode:8;
	    unsigned int w_Dummy:16;
	}       w_T;
	struct {
	    unsigned int w_Stopval:8;
	    unsigned int w_Stopsig:8;
	    unsigned int w_Dummy:16;
	}       w_S;
    }       w_P;
#  else /* mc68000 || sparc || ??? */
#    if defined(_CRAY) || defined(ANY_OTHER_64BIT_MACHINE)
#      define DUMMY_BITS	48
#    else /* _CRAY */
#      define DUMMY_BITS	16
#    endif /* _CRAY */
    union {
	struct {
	    unsigned int w_Dummy:DUMMY_BITS;
	    unsigned int w_Retcode:8;
	    unsigned int w_Coredump:1;
	    unsigned int w_Termsig:7;
	}       w_T;
	struct {
	    unsigned int w_Dummy:DUMMY_BITS;
	    unsigned int w_Stopsig:8;
	    unsigned int w_Stopval:8;
	}       w_S;
    }       w_P;
#  endif /* vax || __vax__ || i386 || _I386 || __i386__ */
};

#  define w_termsig	w_P.w_T.w_Termsig
#  define w_coredump	w_P.w_T.w_Coredump
#  define w_retcode	w_P.w_T.w_Retcode
#  define w_stopval	w_P.w_S.w_Stopval
#  define w_stopsig	w_P.w_S.w_Stopsig
# endif /* _SEQUENT_ */


# ifndef WNOHANG
#  define WNOHANG	1	/* dont hang in wait */
# endif

# ifndef WUNTRACED
#  define WUNTRACED	2	/* tell about stopped, untraced children */
# endif

# define WSTOPPED 0177
# define WIFSTOPPED(x)	((x).w_stopval == WSTOPPED)
# define WIFSIGNALED(x)	(((x).w_stopval != WSTOPPED) && ((x).w_termsig != 0))

#endif /* NEEDwait */

#endif /* _h_tc_wait */
OpenPOWER on IntegriCloud