summaryrefslogtreecommitdiff
path: root/mit-pthreads/machdep/ultrix-4.2/wait.h
blob: 8114f7e461d331115a665da10cf3855dadf5361f (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

#ifndef _SYS_WAIT_H_
#define _SYS_WAIT_H_

#include <ansi_compat.h>
#include <sys/cdefs.h>

#if !defined(_POSIX_SOURCE)
union wait {
#else
union __wait	{
#endif /* !defined(_POSIX_SOURCE) */
#ifdef __vax
	int	w_status;		/* used in syscall */
#endif /* __vax */
#ifdef __mips__
	unsigned int	w_status;		/* used in syscall */
#endif /* __mips */
	/*
	 * Terminated process status.
	 */
	struct {
#ifdef __vax
		unsigned short	w_Termsig:7;	/* termination signal */
		unsigned short	w_Coredump:1;	/* core dump indicator */
		unsigned short	w_Retcode:8;	/* exit code if w_termsig==0 */
#endif /* __vax */
#ifdef __mips__
#ifdef __MIPSEL__
		unsigned int	w_Termsig:7;	/* termination signal */
		unsigned int	w_Coredump:1;	/* core dump indicator */
		unsigned int	w_Retcode:8;	/* exit code if w_termsig==0 */
		unsigned int	w_Filler:16;	/* pad to word boundary */
#endif /* __MIPSEL */
#ifdef __MIPSEB__
		unsigned int	w_Filler:16;	/* pad to word boundary */
		unsigned int	w_Retcode:8;	/* exit code if w_termsig==0 */
		unsigned int	w_Coredump:1;	/* core dump indicator */
		unsigned int	w_Termsig:7;	/* termination signal */
#endif /* __MIPSEB */
#endif /* __mips */
	} w_T;
	/*
	 * Stopped process status.  Returned
	 * only for traced children unless requested
	 * with the WUNTRACED option bit.
	 */
	struct {
#ifdef __vax
		unsigned short	w_Stopval:8;	/* == W_STOPPED if stopped */
		unsigned short	w_Stopsig:8;	/* signal that stopped us */
#endif /* __vax */
#ifdef __mips__
#ifdef __MIPSEL__
		unsigned int	w_Stopval:8;	/* == W_STOPPED if stopped */
		unsigned int	w_Stopsig:8;	/* signal that stopped us */
		unsigned int	w_Filler:16;	/* pad to word boundary */
#endif /* __MIPSEL */
#ifdef __MIPSEB__
		unsigned int	w_Filler:16;	/* pad to word boundary */
		unsigned int	w_Stopsig:8;	/* signal that stopped us */
		unsigned int	w_Stopval:8;	/* == W_STOPPED if stopped */
#endif /* __MIPSEB */
#endif /* __mips */
	} w_S;
};

#if !defined(_POSIX_SOURCE)
#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
#define	WSTOPPED	0177	/* value of s.stopval if process is stopped */
#endif /* !defined(_POSIX_SOURCE) */

#ifdef  WSTOPPED
#define _WSTOPPED	WSTOPPED
#else
#define _WSTOPPED	0177
#endif

/*
 * Option bits for the second argument of wait3.  WNOHANG causes the
 * wait to not hang if there are no stopped or terminated processes, rather
 * returning an error indication in this case (pid==0).  WUNTRACED
 * indicates that the caller should receive status about untraced children
 * which stop due to signals.  If children are stopped and a wait without
 * this option is done, it is as though they were still running... nothing
 * about them is returned.
 */
#define WNOHANG		1	/* dont hang in wait */
#define WUNTRACED	2	/* tell about stopped, untraced children */

/*
 * Must cast as union wait * because POSIX defines the input to these macros
 * as int.
 */

#ifdef _POSIX_SOURCE
#define WIFSTOPPED(x)	(((union __wait *)&(x))->w_S.w_Stopval == _WSTOPPED)
#define WIFSIGNALED(x)	(((union __wait *)&(x))->w_S.w_Stopval != _WSTOPPED && ((union __wait *)&(x))->w_T.w_Termsig != 0)
#define WIFEXITED(x)	(((union __wait *)&(x))->w_S.w_Stopval != _WSTOPPED && ((union __wait *)&(x))->w_T.w_Termsig == 0)
#define	WEXITSTATUS(x)	(((union __wait *)&(x))->w_T.w_Retcode)
#define	WTERMSIG(x)	(((union __wait *)&(x))->w_T.w_Termsig)
#define	WSTOPSIG(x)	(((union __wait *)&(x))->w_S.w_Stopsig)
#endif /* _POSIX_SOURCE */

#if !defined(_POSIX_SOURCE)
#define WIFSTOPPED(x)	(((union wait *)&(x))->w_stopval == WSTOPPED)
#define WIFSIGNALED(x)	(((union wait *)&(x))->w_stopval != WSTOPPED && ((union wait *)&(x))->w_termsig != 0)
#define WIFEXITED(x)	(((union wait *)&(x))->w_stopval != WSTOPPED && ((union wait *)&(x))->w_termsig == 0)
#define	WEXITSTATUS(x)	(((union wait *)&(x))->w_retcode)
#define	WTERMSIG(x)	(((union wait *)&(x))->w_termsig)
#define	WSTOPSIG(x)	(((union wait *)&(x))->w_stopsig)
#endif /* !defined(_POSIX_SOURCE) */

pid_t wait 					__P_((int *));
pid_t waitpid 				__P_((pid_t, int *, int));

#endif /* _SYS_WAIT_H_ */