wait.h

Go to the documentation of this file.
00001 /*-
00002  * Copyright (c) 1982, 1986, 1989, 1993, 1994
00003  *      The Regents of the University of California.  All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 4. Neither the name of the University nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  * © Portions copyright (c) 2007 Symbian Software Ltd. All rights reserved.
00029  *      @(#)wait.h      8.2 (Berkeley) 7/10/94
00030  * $FreeBSD: src/sys/sys/wait.h,v 1.21 2005/01/05 22:19:44 jhb Exp $
00031  */
00032 
00033 #ifndef _SYS_WAIT_H_
00034 #define _SYS_WAIT_H_
00035 
00036 #include <sys/cdefs.h>
00037 
00038 /*
00039  * This file holds definitions relevant to the wait4 system call and the
00040  * alternate interfaces that use it (wait, wait3, waitpid).
00041  */
00042 
00043 /*
00044  * Macros to test the exit status returned by wait and extract the relevant
00045  * values.
00046  */
00047 #if __BSD_VISIBLE
00048 #define _W_INT(w)       (*(int *)&(w))  /* Convert union wait to int. */
00049 #define WCOREFLAG       0200
00050 #else
00051 #define _W_INT(i)       (i)
00052 #endif
00053 
00054 #define _WSTATUS(x)     (_W_INT(x) & 0177)
00055 #define _WSTOPPED       0177            /* _WSTATUS if process is stopped */
00056 #define WIFSTOPPED(x)   (_WSTATUS(x) == _WSTOPPED)
00057 #define WSTOPSIG(x)     (_W_INT(x) >> 8)
00058 #define WIFSIGNALED(x)  (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
00059 #define WTERMSIG(x)     (_WSTATUS(x))
00060 #define WIFEXITED(x)    (_WSTATUS(x) == 0)
00061 #define WEXITSTATUS(x)  (_W_INT(x) >> 8)
00062 #define WIFCONTINUED(x) (x == 0x13)     /* 0x13 == SIGCONT */
00063 #if __BSD_VISIBLE
00064 #define WCOREDUMP(x)    (_W_INT(x) & WCOREFLAG)
00065 
00066 #define W_EXITCODE(ret, sig)    ((ret) << 8 | (sig))
00067 #define W_STOPCODE(sig)         ((sig) << 8 | _WSTOPPED)
00068 #endif
00069 
00070 /*
00071  * Option bits for the third argument of wait4.  WNOHANG causes the
00072  * wait to not hang if there are no stopped or terminated processes, rather
00073  * returning an error indication in this case (pid==0).  WUNTRACED
00074  * indicates that the caller should receive status about untraced children
00075  * which stop due to signals.  If children are stopped and a wait without
00076  * this option is done, it is as though they were still running... nothing
00077  * about them is returned.
00078  */
00079 #define WNOHANG         1       /* Don't hang in wait. */
00080 #define WUNTRACED       2       /* Tell about stopped, untraced children. */
00081 #define WCONTINUED      4       /* Report a job control continued process. */
00082 
00083 #if __BSD_VISIBLE
00084 #define WLINUXCLONE 0x80000000  /* Wait for kthread spawned from linux_clone. */
00085 #endif
00086 
00087 /*
00088  * Tokens for special values of the "pid" parameter to wait4.
00089  */
00090 #if __BSD_VISIBLE
00091 #define WAIT_ANY        (-1)    /* any process */
00092 #define WAIT_MYPGRP     0       /* any process in my process group */
00093 #endif /* __BSD_VISIBLE */
00094 
00095 #ifndef _KERNEL
00096 #include <sys/types.h>
00097 
00098 __BEGIN_DECLS
00099 IMPORT_C
00100 pid_t   wait(int *);
00101 IMPORT_C
00102 pid_t   waitpid(pid_t, int *, int);
00103 #if __BSD_VISIBLE
00104 struct rusage;
00105 #endif
00106 __END_DECLS
00107 #endif /* !_KERNEL */
00108 
00109 #endif /* !_SYS_WAIT_H_ */

Copyright © Nokia Corporation 2001-2008
Back to top