Sat Apr 2 11:18:26 2016 UTC ()
correct the definition of WSTOPPED


(christos)
diff -r1.26 -r1.27 src/sys/sys/wait.h

cvs diff -r1.26 -r1.27 src/sys/sys/wait.h (switch to unified diff)

--- src/sys/sys/wait.h 2009/01/11 02:45:56 1.26
+++ src/sys/sys/wait.h 2016/04/02 11:18:26 1.27
@@ -1,186 +1,186 @@ @@ -1,186 +1,186 @@
1/* $NetBSD: wait.h,v 1.26 2009/01/11 02:45:56 christos Exp $ */ 1/* $NetBSD: wait.h,v 1.27 2016/04/02 11:18:26 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1986, 1989, 1993, 1994 4 * Copyright (c) 1982, 1986, 1989, 1993, 1994
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors 15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software 16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission. 17 * without specific prior written permission.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 * 30 *
31 * @(#)wait.h 8.2 (Berkeley) 7/10/94 31 * @(#)wait.h 8.2 (Berkeley) 7/10/94
32 */ 32 */
33 33
34#ifndef _SYS_WAIT_H_ 34#ifndef _SYS_WAIT_H_
35#define _SYS_WAIT_H_ 35#define _SYS_WAIT_H_
36 36
37#include <sys/featuretest.h> 37#include <sys/featuretest.h>
38 38
39/* 39/*
40 * This file holds definitions relevent to the wait4 system call 40 * This file holds definitions relevent to the wait4 system call
41 * and the alternate interfaces that use it (wait, wait3, waitpid). 41 * and the alternate interfaces that use it (wait, wait3, waitpid).
42 */ 42 */
43 43
44/* 44/*
45 * Macros to test the exit status returned by wait 45 * Macros to test the exit status returned by wait
46 * and extract the relevant values. 46 * and extract the relevant values.
47 */ 47 */
48#if !( defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) ) || defined(_KERNEL) 48#if !( defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) ) || defined(_KERNEL)
49#define _W_INT(i) (i) 49#define _W_INT(i) (i)
50#else 50#else
51#define _W_INT(w) (*(int *)(void *)&(w)) /* convert union wait to int */ 51#define _W_INT(w) (*(int *)(void *)&(w)) /* convert union wait to int */
52#endif 52#endif
53 53
54#define _WSTATUS(x) (_W_INT(x) & 0177) 54#define _WSTATUS(x) (_W_INT(x) & 0177)
55#define _WSTOPPED 0177 /* _WSTATUS if process is stopped */ 55#define _WSTOPPED 0177 /* _WSTATUS if process is stopped */
56#define WIFSTOPPED(x) (_WSTATUS(x) == _WSTOPPED) 56#define WIFSTOPPED(x) (_WSTATUS(x) == _WSTOPPED)
57#define WSTOPSIG(x) ((int)(((unsigned int)_W_INT(x)) >> 8) & 0xff) 57#define WSTOPSIG(x) ((int)(((unsigned int)_W_INT(x)) >> 8) & 0xff)
58#define WIFSIGNALED(x) (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0) 58#define WIFSIGNALED(x) (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
59#define WTERMSIG(x) (_WSTATUS(x)) 59#define WTERMSIG(x) (_WSTATUS(x))
60#define WIFEXITED(x) (_WSTATUS(x) == 0) 60#define WIFEXITED(x) (_WSTATUS(x) == 0)
61#define WEXITSTATUS(x) ((int)(((unsigned int)_W_INT(x)) >> 8) & 0xff) 61#define WEXITSTATUS(x) ((int)(((unsigned int)_W_INT(x)) >> 8) & 0xff)
62#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) || defined(_KERNEL) 62#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) || defined(_KERNEL)
63#define WCOREFLAG 0200 63#define WCOREFLAG 0200
64#define WCOREDUMP(x) (_W_INT(x) & WCOREFLAG) 64#define WCOREDUMP(x) (_W_INT(x) & WCOREFLAG)
65 65
66#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig)) 66#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
67#define W_STOPCODE(sig) ((sig) << 8 | _WSTOPPED) 67#define W_STOPCODE(sig) ((sig) << 8 | _WSTOPPED)
68#endif 68#endif
69 69
70/* 70/*
71 * Option bits for the third argument of wait4. WNOHANG causes the 71 * Option bits for the third argument of wait4. WNOHANG causes the
72 * wait to not hang if there are no stopped or terminated processes, rather 72 * wait to not hang if there are no stopped or terminated processes, rather
73 * returning an error indication in this case (pid==0). WUNTRACED 73 * returning an error indication in this case (pid==0). WUNTRACED
74 * indicates that the caller should receive status about untraced children 74 * indicates that the caller should receive status about untraced children
75 * which stop due to signals. If children are stopped and a wait without 75 * which stop due to signals. If children are stopped and a wait without
76 * this option is done, it is as though they were still running... nothing 76 * this option is done, it is as though they were still running... nothing
77 * about them is returned. 77 * about them is returned.
78 */ 78 */
79#define WNOHANG 0x00000001 /* don't hang in wait */ 79#define WNOHANG 0x00000001 /* don't hang in wait */
80#define WUNTRACED 0x00000002 /* tell about stopped, 80#define WUNTRACED 0x00000002 /* tell about stopped,
81 untraced children */ 81 untraced children */
 82#define WSTOPPED WUNTRACED /* SUS compatibility */
82#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) 83#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
83#define WALTSIG 0x00000004 /* wait for processes that exit 84#define WALTSIG 0x00000004 /* wait for processes that exit
84 with an alternate signal (i.e. 85 with an alternate signal (i.e.
85 not SIGCHLD) */ 86 not SIGCHLD) */
86#define WALLSIG 0x00000008 /* wait for processes that exit 87#define WALLSIG 0x00000008 /* wait for processes that exit
87 with any signal, i.e. SIGCHLD 88 with any signal, i.e. SIGCHLD
88 and alternates */ 89 and alternates */
89 90
90/* 91/*
91 * These are the Linux names of some of the above flags, for compatibility 92 * These are the Linux names of some of the above flags, for compatibility
92 * with Linux's clone(2) API. 93 * with Linux's clone(2) API.
93 */ 94 */
94#define __WCLONE WALTSIG 95#define __WCLONE WALTSIG
95#define __WALL WALLSIG 96#define __WALL WALLSIG
96 97
97/* 98/*
98 * These bits are used in order to support SVR4 (etc) functionality 99 * These bits are used in order to support SVR4 (etc) functionality
99 * without replicating sys_wait4 5 times. 100 * without replicating sys_wait4 5 times.
100 */ 101 */
101#define WNOWAIT 0x00010000 /* Don't mark child 'P_WAITED' */ 102#define WNOWAIT 0x00010000 /* Don't mark child 'P_WAITED' */
102#define WNOZOMBIE 0x00020000 /* Ignore zombies */ 103#define WNOZOMBIE 0x00020000 /* Ignore zombies */
103#define WOPTSCHECKED 0x00040000 /* Compat call, options verified */ 104#define WOPTSCHECKED 0x00040000 /* Compat call, options verified */
104#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ 105#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
105 106
106#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) 107#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
107/* POSIX extensions and 4.2/4.3 compatibility: */ 108/* POSIX extensions and 4.2/4.3 compatibility: */
108 109
109/* 110/*
110 * Tokens for special values of the "pid" parameter to wait4. 111 * Tokens for special values of the "pid" parameter to wait4.
111 */ 112 */
112#define WAIT_ANY (-1) /* any process */ 113#define WAIT_ANY (-1) /* any process */
113#define WAIT_MYPGRP 0 /* any process in my process group */ 114#define WAIT_MYPGRP 0 /* any process in my process group */
114 115
115#include <sys/types.h> 116#include <sys/types.h>
116 117
117/* 118/*
118 * Deprecated: 119 * Deprecated:
119 * Structure of the information in the status word returned by wait4. 120 * Structure of the information in the status word returned by wait4.
120 * If w_stopval==WSTOPPED, then the second structure describes 121 * If w_stopval==WSTOPPED, then the second structure describes
121 * the information returned, else the first. 122 * the information returned, else the first.
122 */ 123 */
123union wait { 124union wait {
124 int w_status; /* used in syscall */ 125 int w_status; /* used in syscall */
125 /* 126 /*
126 * Terminated process status. 127 * Terminated process status.
127 */ 128 */
128 struct { 129 struct {
129#if BYTE_ORDER == LITTLE_ENDIAN 130#if BYTE_ORDER == LITTLE_ENDIAN
130 unsigned int w_Termsig:7, /* termination signal */ 131 unsigned int w_Termsig:7, /* termination signal */
131 w_Coredump:1, /* core dump indicator */ 132 w_Coredump:1, /* core dump indicator */
132 w_Retcode:8, /* exit code if w_termsig==0 */ 133 w_Retcode:8, /* exit code if w_termsig==0 */
133 w_Filler:16; /* upper bits filler */ 134 w_Filler:16; /* upper bits filler */
134#endif 135#endif
135#if BYTE_ORDER == BIG_ENDIAN 136#if BYTE_ORDER == BIG_ENDIAN
136 unsigned int w_Filler:16, /* upper bits filler */ 137 unsigned int w_Filler:16, /* upper bits filler */
137 w_Retcode:8, /* exit code if w_termsig==0 */ 138 w_Retcode:8, /* exit code if w_termsig==0 */
138 w_Coredump:1, /* core dump indicator */ 139 w_Coredump:1, /* core dump indicator */
139 w_Termsig:7; /* termination signal */ 140 w_Termsig:7; /* termination signal */
140#endif 141#endif
141 } w_T; 142 } w_T;
142 /* 143 /*
143 * Stopped process status. Returned 144 * Stopped process status. Returned
144 * only for traced children unless requested 145 * only for traced children unless requested
145 * with the WUNTRACED option bit. 146 * with the WUNTRACED option bit.
146 */ 147 */
147 struct { 148 struct {
148#if BYTE_ORDER == LITTLE_ENDIAN 149#if BYTE_ORDER == LITTLE_ENDIAN
149 unsigned int w_Stopval:8, /* == W_STOPPED if stopped */ 150 unsigned int w_Stopval:8, /* == W_STOPPED if stopped */
150 w_Stopsig:8, /* signal that stopped us */ 151 w_Stopsig:8, /* signal that stopped us */
151 w_Filler:16; /* upper bits filler */ 152 w_Filler:16; /* upper bits filler */
152#endif 153#endif
153#if BYTE_ORDER == BIG_ENDIAN 154#if BYTE_ORDER == BIG_ENDIAN
154 unsigned int w_Filler:16, /* upper bits filler */ 155 unsigned int w_Filler:16, /* upper bits filler */
155 w_Stopsig:8, /* signal that stopped us */ 156 w_Stopsig:8, /* signal that stopped us */
156 w_Stopval:8; /* == W_STOPPED if stopped */ 157 w_Stopval:8; /* == W_STOPPED if stopped */
157#endif 158#endif
158 } w_S; 159 } w_S;
159}; 160};
160#define w_termsig w_T.w_Termsig 161#define w_termsig w_T.w_Termsig
161#define w_coredump w_T.w_Coredump 162#define w_coredump w_T.w_Coredump
162#define w_retcode w_T.w_Retcode 163#define w_retcode w_T.w_Retcode
163#define w_stopval w_S.w_Stopval 164#define w_stopval w_S.w_Stopval
164#define w_stopsig w_S.w_Stopsig 165#define w_stopsig w_S.w_Stopsig
165 166
166#define WSTOPPED _WSTOPPED 
167#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ 167#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
168 168
169#ifndef _KERNEL 169#ifndef _KERNEL
170#include <sys/cdefs.h> 170#include <sys/cdefs.h>
171 171
172__BEGIN_DECLS 172__BEGIN_DECLS
173struct rusage; /* forward declaration */ 173struct rusage; /* forward declaration */
174 174
175pid_t wait(int *); 175pid_t wait(int *);
176pid_t waitpid(pid_t, int *, int); 176pid_t waitpid(pid_t, int *, int);
177#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) 177#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
178#ifndef __LIBC12_SOURCE__ 178#ifndef __LIBC12_SOURCE__
179pid_t wait3(int *, int, struct rusage *) __RENAME(__wait350); 179pid_t wait3(int *, int, struct rusage *) __RENAME(__wait350);
180pid_t wait4(pid_t, int *, int, struct rusage *) __RENAME(__wait450); 180pid_t wait4(pid_t, int *, int, struct rusage *) __RENAME(__wait450);
181#endif 181#endif
182#endif 182#endif
183__END_DECLS 183__END_DECLS
184#endif 184#endif
185 185
186#endif /* !_SYS_WAIT_H_ */ 186#endif /* !_SYS_WAIT_H_ */