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