/* $NetBSD: wait.h,v 1.26 2009/01/11 02:45:56 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)wait.h 8.2 (Berkeley) 7/10/94 */ #ifndef _SYS_WAIT_H_ #define _SYS_WAIT_H_ #include #include #include /* The header contains macros related to wait(). The value * returned by wait() and waitpid() depends on whether the process * terminated by an exit() call, was killed by a signal, or was stopped * due to job control, as follows: * * High byte Low byte * +---------------------+ * exit(status) | status | 0 | * +---------------------+ * killed by signal | 0 | signal | * +---------------------+ * stopped (job control) | signal | 0177 | * +---------------------+ */ /* * Macros to test the exit status returned by wait * and extract the relevant values. */ #define _LOW(v) ( (v) & 0377) #define _HIGH(v) ( ((v) >> 8) & 0377) #define WIFEXITED(s) (_LOW(s) == 0) /* normal exit */ #define WEXITSTATUS(s) (_HIGH(s)) /* exit status */ #define WTERMSIG(s) (_LOW(s) & 0177) /* sig value */ #define WIFSIGNALED(s) ((((unsigned int)(s)-1) & 0xFFFFU) < 0xFFU) /* signaled */ #define WIFSTOPPED(s) (_LOW(s) == 0177) /* stopped */ #define WSTOPSIG(s) (_HIGH(s) & 0377) /* stop signal */ /* * Option bits for the third argument of waitpid. 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 0x00000001 /* don't hang in wait */ #define WUNTRACED 0x00000002 /* tell about stopped, untraced children */ /* POSIX extensions and 4.2/4.3 compatibility: */ /* * Tokens for special values of the "pid" parameter to waitpid. */ #define WAIT_ANY (-1) /* any process */ #define WAIT_MYPGRP 0 /* any process in my process group */ __BEGIN_DECLS pid_t wait(int *); pid_t waitpid(pid_t, int *, int); __END_DECLS #endif /* !_SYS_WAIT_H_ */