FreeBSD/Linux Kernel Cross Reference
sys/sys/wait.h
1 /*-
2 * Copyright (c) 1982, 1986, 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)wait.h 8.2 (Berkeley) 7/10/94
34 * $FreeBSD: releng/5.2/sys/sys/wait.h 97851 2002-06-05 02:21:01Z mike $
35 */
36
37 #ifndef _SYS_WAIT_H_
38 #define _SYS_WAIT_H_
39
40 #include <sys/cdefs.h>
41
42 /*
43 * This file holds definitions relevant to the wait4 system call and the
44 * alternate interfaces that use it (wait, wait3, waitpid).
45 */
46
47 /*
48 * Macros to test the exit status returned by wait and extract the relevant
49 * values.
50 */
51 #if __BSD_VISIBLE
52 #define _W_INT(w) (*(int *)&(w)) /* Convert union wait to int. */
53 #define WCOREFLAG 0200
54 #else
55 #define _W_INT(i) (i)
56 #endif
57
58 #define _WSTATUS(x) (_W_INT(x) & 0177)
59 #define _WSTOPPED 0177 /* _WSTATUS if process is stopped */
60 #define WIFSTOPPED(x) (_WSTATUS(x) == _WSTOPPED)
61 #define WSTOPSIG(x) (_W_INT(x) >> 8)
62 #define WIFSIGNALED(x) (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
63 #define WTERMSIG(x) (_WSTATUS(x))
64 #define WIFEXITED(x) (_WSTATUS(x) == 0)
65 #define WEXITSTATUS(x) (_W_INT(x) >> 8)
66 #define WIFCONTINUED(x) (x == 0x13) /* 0x13 == SIGCONT */
67 #if __BSD_VISIBLE
68 #define WCOREDUMP(x) (_W_INT(x) & WCOREFLAG)
69
70 #define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
71 #define W_STOPCODE(sig) ((sig) << 8 | _WSTOPPED)
72 #endif
73
74 /*
75 * Option bits for the third argument of wait4. WNOHANG causes the
76 * wait to not hang if there are no stopped or terminated processes, rather
77 * returning an error indication in this case (pid==0). WUNTRACED
78 * indicates that the caller should receive status about untraced children
79 * which stop due to signals. If children are stopped and a wait without
80 * this option is done, it is as though they were still running... nothing
81 * about them is returned.
82 */
83 #define WNOHANG 1 /* Don't hang in wait. */
84 #define WUNTRACED 2 /* Tell about stopped, untraced children. */
85 #define WCONTINUED 4 /* Report a job control continued process. */
86
87 #if __BSD_VISIBLE
88 #define WLINUXCLONE 0x80000000 /* Wait for kthread spawned from linux_clone. */
89 #endif
90
91 /*
92 * Tokens for special values of the "pid" parameter to wait4.
93 */
94 #if __BSD_VISIBLE
95 #define WAIT_ANY (-1) /* any process */
96 #define WAIT_MYPGRP 0 /* any process in my process group */
97 #endif /* __BSD_VISIBLE */
98
99 #ifndef _KERNEL
100 #include <sys/types.h>
101
102 __BEGIN_DECLS
103 struct rusage; /* forward declaration */
104
105 pid_t wait(int *);
106 pid_t waitpid(pid_t, int *, int);
107 #if __BSD_VISIBLE
108 pid_t wait3(int *, int, struct rusage *);
109 pid_t wait4(pid_t, int *, int, struct rusage *);
110 #endif
111 __END_DECLS
112 #endif
113
114 #endif /* !_SYS_WAIT_H_ */
Cache object: 72ff264c0dc1cddc880a482b6c368627
|