Project

General

Profile

Statistics
| Branch: | Revision:

scoutos / prex-0.9.0 / include / sys / wait.h @ 03e9c04a

History | View | Annotate | Download (5.01 KB)

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
 */
31

    
32
#ifndef _SYS_WAIT_H_
33
#define _SYS_WAIT_H_
34

    
35
/*
36
 * This file holds definitions relevent to the wait4 system call
37
 * and the alternate interfaces that use it (wait, wait3, waitpid).
38
 */
39

    
40
/*
41
 * Macros to test the exit status returned by wait
42
 * and extract the relevant values.
43
 */
44
#ifdef _POSIX_SOURCE
45
#define        _W_INT(i)        (i)
46
#else
47
#define        _W_INT(w)        (*(int *)&(w))        /* convert union wait to int */
48
#define        WCOREFLAG        0200
49
#endif
50

    
51
#define        _WSTATUS(x)        (_W_INT(x) & 0177)
52
#define        _WSTOPPED        0177                /* _WSTATUS if process is stopped */
53
#define WIFSTOPPED(x)        (_WSTATUS(x) == _WSTOPPED)
54
#define WSTOPSIG(x)        (_W_INT(x) >> 8)
55
#define WIFSIGNALED(x)        (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
56
#define WTERMSIG(x)        (_WSTATUS(x))
57
#define WIFEXITED(x)        (_WSTATUS(x) == 0)
58
#define WEXITSTATUS(x)        (_W_INT(x) >> 8)
59
#ifndef _POSIX_SOURCE
60
#define WCOREDUMP(x)        (_W_INT(x) & WCOREFLAG)
61

    
62
#define        W_EXITCODE(ret, sig)        ((ret) << 8 | (sig))
63
#define        W_STOPCODE(sig)                ((sig) << 8 | _WSTOPPED)
64
#endif
65

    
66
/*
67
 * Option bits for the third argument of wait4.  WNOHANG causes the
68
 * wait to not hang if there are no stopped or terminated processes, rather
69
 * returning an error indication in this case (pid==0).  WUNTRACED
70
 * indicates that the caller should receive status about untraced children
71
 * which stop due to signals.  If children are stopped and a wait without
72
 * this option is done, it is as though they were still running... nothing
73
 * about them is returned.
74
 */
75
#define WNOHANG                1        /* don't hang in wait */
76
#define WUNTRACED        2        /* tell about stopped, untraced children */
77

    
78
#ifndef _POSIX_SOURCE
79
/* POSIX extensions and 4.2/4.3 compatability: */
80

    
81
/*
82
 * Tokens for special values of the "pid" parameter to wait4.
83
 */
84
#define        WAIT_ANY        (-1)        /* any process */
85
#define        WAIT_MYPGRP        0        /* any process in my process group */
86

    
87
#include <sys/endian.h>
88

    
89
/*
90
 * Deprecated:
91
 * Structure of the information in the status word returned by wait4.
92
 * If w_stopval==WSTOPPED, then the second structure describes
93
 * the information returned, else the first.
94
 */
95
union wait {
96
        int        w_status;                /* used in syscall */
97
        /*
98
         * Terminated process status.
99
         */
100
        struct {
101
#if BYTE_ORDER == LITTLE_ENDIAN
102
                unsigned int        w_Termsig:7,        /* termination signal */
103
                                w_Coredump:1,        /* core dump indicator */
104
                                w_Retcode:8,        /* exit code if w_termsig==0 */
105
                                w_Filler:16;        /* upper bits filler */
106
#endif
107
#if BYTE_ORDER == BIG_ENDIAN
108
                unsigned int        w_Filler:16,        /* upper bits filler */
109
                                w_Retcode:8,        /* exit code if w_termsig==0 */
110
                                w_Coredump:1,        /* core dump indicator */
111
                                w_Termsig:7;        /* termination signal */
112
#endif
113
        } w_T;
114
        /*
115
         * Stopped process status.  Returned
116
         * only for traced children unless requested
117
         * with the WUNTRACED option bit.
118
         */
119
        struct {
120
#if BYTE_ORDER == LITTLE_ENDIAN
121
                unsigned int        w_Stopval:8,        /* == W_STOPPED if stopped */
122
                                w_Stopsig:8,        /* signal that stopped us */
123
                                w_Filler:16;        /* upper bits filler */
124
#endif
125
#if BYTE_ORDER == BIG_ENDIAN
126
                unsigned int        w_Filler:16,        /* upper bits filler */
127
                                w_Stopsig:8,        /* signal that stopped us */
128
                                w_Stopval:8;        /* == W_STOPPED if stopped */
129
#endif
130
        } w_S;
131
};
132
#define        w_termsig        w_T.w_Termsig
133
#define w_coredump        w_T.w_Coredump
134
#define w_retcode        w_T.w_Retcode
135
#define w_stopval        w_S.w_Stopval
136
#define w_stopsig        w_S.w_Stopsig
137

    
138
#define        WSTOPPED        _WSTOPPED
139
#endif /* _POSIX_SOURCE */
140

    
141
#ifndef KERNEL
142
#include <sys/types.h>
143
#include <sys/cdefs.h>
144

    
145
__BEGIN_DECLS
146
pid_t        wait(int *);
147
pid_t        waitpid(pid_t, int *, int);
148
__END_DECLS
149
#endif
150

    
151
#endif /* !_SYS_WAIT_H_ */