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. Neither the name of the University nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)wait.h 8.2 (Berkeley) 7/10/94 30 * $FreeBSD: src/sys/sys/wait.h,v 1.11 1999/12/29 04:24:50 peter Exp $ 31 */ 32 33 #ifndef _SYS_WAIT_H_ 34 #define _SYS_WAIT_H_ 35 36 #include <sys/cdefs.h> 37 #include <machine/stdint.h> 38 39 /* 40 * This file holds definitions relevant to the wait4 system call 41 * and the alternate interfaces that use it (wait, wait3, waitpid). 42 */ 43 44 /* 45 * Macros to test the exit status returned by wait 46 * and extract the relevant values. 47 */ 48 #if __BSD_VISIBLE 49 #define WCOREFLAG 0200 50 #endif 51 #define _W_INT(i) (i) 52 53 #define _WSTATUS(x) (_W_INT(x) & 0177) 54 #define _WSTOPPED 0177 /* _WSTATUS if process is stopped */ 55 #define WIFSTOPPED(x) (_WSTATUS(x) == _WSTOPPED) 56 #define WIFCONTINUED(x) (x == 19) /* 19 == SIGCONT */ 57 #define WIFEXITED(x) (_WSTATUS(x) == 0) 58 #define WIFSIGNALED(x) (!WIFSTOPPED(x) && !WIFCONTINUED(x) && !WIFEXITED(x)) 59 #define WSTOPSIG(x) (_W_INT(x) >> 8) 60 #define WTERMSIG(x) (_WSTATUS(x)) 61 #define WEXITSTATUS(x) (_W_INT(x) >> 8) 62 #if __BSD_VISIBLE 63 #define WCOREDUMP(x) (_W_INT(x) & WCOREFLAG) 64 65 #define W_EXITCODE(ret, sig) ((ret) << 8 | (sig)) 66 #define W_STOPCODE(sig) ((sig) << 8 | _WSTOPPED) 67 #endif 68 69 /* 70 * Option bits for the third argument of wait4. WNOHANG causes the 71 * wait to not hang if there are no stopped or terminated processes, rather 72 * returning an error indication in this case (pid==0). WUNTRACED 73 * indicates that the caller should receive status about untraced children 74 * which stop due to signals. If children are stopped and a wait without 75 * this option is done, it is as though they were still running... nothing 76 * about them is returned. 77 */ 78 #define WNOHANG 0x0001 /* don't hang in wait */ 79 #define WUNTRACED 0x0002 /* tell about stopped, untraced children */ 80 #define WCONTINUED 0x0004 /* Report a job control continued process. */ 81 #define WSTOPPED WUNTRACED 82 #define WNOWAIT 0x0008 83 #define WEXITED 0x0010 84 #define WTRAPPED 0x0020 85 86 #if __BSD_VISIBLE 87 #define WLINUXCLONE 0x80000000 /* wait for kthread spawned from linux_clone */ 88 89 /* 90 * Tokens for special values of the "pid" parameter to wait4. 91 */ 92 #define WAIT_ANY (-1) /* any process */ 93 #define WAIT_MYPGRP 0 /* any process in my process group */ 94 #endif /* __BSD_VISIBLE */ 95 96 #ifndef _ID_T_DECLARED 97 #define _ID_T_DECLARED 98 typedef __int64_t id_t; /* general id, can hold gid/pid/uid_t */ 99 #endif 100 101 #ifndef _IDTYPE_T_DECLARED 102 #define _IDTYPE_T_DECLARED 103 104 /* SEE ALSO SYS/PROCCTL.H */ 105 106 typedef enum 107 #if __BSD_VISIBLE 108 idtype 109 #endif 110 { 111 /* 112 * These names were mostly lifted from Solaris source code and 113 * still use Solaris style naming to avoid breaking any 114 * OpenSolaris code which has been ported to FreeBSD/DragonFly. 115 * There is no clear DragonFly counterpart for all of the names, but 116 * some have a clear correspondence to DragonFly entities. 117 * 118 * The numerical values are kept synchronized with the Solaris 119 * values. 120 */ 121 P_PID, /* A process identifier. */ 122 P_PPID, /* A parent process identifier. */ 123 P_PGID, /* A process group identifier. */ 124 P_SID, /* A session identifier. */ 125 P_CID, /* A scheduling class identifier. */ 126 P_UID, /* A user identifier. */ 127 P_GID, /* A group identifier. */ 128 P_ALL, /* All processes. */ 129 P_LWPID, /* An LWP identifier. */ 130 P_TASKID, /* A task identifier. */ 131 P_PROJID, /* A project identifier. */ 132 P_POOLID, /* A pool identifier. */ 133 P_JAILID, /* A zone identifier. */ 134 P_CTID, /* A (process) contract identifier. */ 135 P_CPUID, /* CPU identifier. */ 136 P_PSETID /* Processor set identifier. */ 137 } idtype_t; /* The type of id_t we are using. */ 138 139 #endif 140 141 #if !defined(_KERNEL) || defined(_KERNEL_VIRTUAL) 142 #include <sys/_siginfo.h> 143 144 #ifndef _PID_T_DECLARED 145 typedef __pid_t pid_t; /* process id */ 146 #define _PID_T_DECLARED 147 #endif 148 149 __BEGIN_DECLS 150 pid_t wait(int *); 151 pid_t waitpid(pid_t, int *, int); 152 #if __POSIX_VISIBLE >= 200112 153 int waitid(idtype_t, id_t, siginfo_t *, int); 154 #endif 155 #if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 700) 156 struct rusage; 157 struct __wrusage; 158 #endif 159 #if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 600) 160 pid_t wait3(int *, int, struct rusage *); 161 #endif 162 #if __BSD_VISIBLE 163 pid_t wait4(pid_t, int *, int, struct rusage *); 164 pid_t wait6(idtype_t, id_t, int *, int, struct __wrusage *, 165 siginfo_t *); 166 #endif 167 __END_DECLS 168 #endif 169 170 #endif 171