OSDN Git Service

9dd8bf7dcd446fc738e1d4c3484770debdda6f33
[pf3gnuchains/sourceware.git] / winsup / cygwin / include / sys / wait.h
1 /* sys/wait.h
2
3    Copyright 1997, 1998, 2001 Red Hat, Inc.
4
5 This file is part of Cygwin.
6
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
9 details. */
10
11 #ifndef _SYS_WAIT_H
12 #define _SYS_WAIT_H
13
14 #include <sys/types.h>
15 #include <sys/resource.h>
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 #define WNOHANG 1
22 #define WUNTRACED 2
23
24 /* A status looks like:
25       <2 bytes info> <2 bytes code>
26
27       <code> == 0, child has exited, info is the exit value
28       <code> == 1..7e, child has exited, info is the signal number.
29       <code> == 7f, child has stopped, info was the signal number.
30       <code> == 80, there was a core dump.
31 */
32
33 #define WIFEXITED(w)    (((w) & 0xff) == 0)
34 #define WIFSIGNALED(w)  (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
35 #define WIFSTOPPED(w)   (((w) & 0xff) == 0x7f)
36 #define WEXITSTATUS(w)  (((w) >> 8) & 0xff)
37 #define WTERMSIG(w)     ((w) & 0x7f)
38 #define WSTOPSIG        WEXITSTATUS
39
40 pid_t wait (int *);
41 pid_t waitpid (pid_t, int *, int);
42 pid_t wait3 (int *__status, int __options, struct rusage *__rusage);
43 pid_t wait4 (pid_t __pid, int *__status, int __options, struct rusage *__rusage);
44
45 union wait
46   {
47     int w_status;
48     struct
49       {
50         unsigned int __w_termsig:7; /* Terminating signal.  */
51         unsigned int __w_coredump:1; /* Set if dumped core.  */
52         unsigned int __w_retcode:8; /* Return code if exited normally.  */
53         unsigned int:16;
54       } __wait_terminated;
55     struct
56       {
57         unsigned int __w_stopval:8; /* W_STOPPED if stopped.  */
58         unsigned int __w_stopsig:8; /* Stopping signal.  */
59         unsigned int:16;
60       } __wait_stopped;
61   };
62
63 #define w_termsig       __wait_terminated.__w_termsig
64 #define w_coredump      __wait_terminated.__w_coredump
65 #define w_retcode       __wait_terminated.__w_retcode
66 #define w_stopsig       __wait_stopped.__w_stopsig
67 #define w_stopval       __wait_stopped.__w_stopval
68
69 #ifdef __cplusplus
70 };
71 #endif
72
73 #endif