comparison druntime/import/core/sys/posix/sys/wait.d @ 1458:e0b2d67cfe7c

Added druntime (this should be removed once it works).
author Robert Clipsham <robert@octarineparrot.com>
date Tue, 02 Jun 2009 17:43:06 +0100
parents
children
comparison
equal deleted inserted replaced
1456:7b218ec1044f 1458:e0b2d67cfe7c
1 /**
2 * D header file for POSIX.
3 *
4 * Copyright: Copyright Sean Kelly 2005 - 2009.
5 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
6 * Authors: Sean Kelly
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8 *
9 * Copyright Sean Kelly 2005 - 2009.
10 * Distributed under the Boost Software License, Version 1.0.
11 * (See accompanying file LICENSE_1_0.txt or copy at
12 * http://www.boost.org/LICENSE_1_0.txt)
13 */
14 module core.sys.posix.sys.wait;
15
16 private import core.sys.posix.config;
17 public import core.sys.posix.sys.types; // for id_t, pid_t
18 public import core.sys.posix.signal; // for siginfo_t (XSI)
19 //public import core.sys.posix.resource; // for rusage (XSI)
20
21 extern (C):
22
23 //
24 // Required
25 //
26 /*
27 WNOHANG
28 WUNTRACED
29
30 WEXITSTATUS
31 WIFCONTINUED
32 WIFEXITED
33 WIFSIGNALED
34 WIFSTOPPED
35 WSTOPSIG
36 WTERMSIG
37
38 pid_t wait(int*);
39 pid_t waitpid(pid_t, int*, int);
40 */
41
42 version( linux )
43 {
44 enum WNOHANG = 1;
45 enum WUNTRACED = 2;
46
47 private
48 {
49 enum __W_CONTINUED = 0xFFFF;
50
51 extern (D) int __WTERMSIG( int status ) { return status & 0x7F; }
52 }
53
54 //
55 // NOTE: These macros assume __USE_BSD is not defined in the relevant
56 // C headers as the parameter definition there is different and
57 // much more complicated.
58 //
59 extern (D) int WEXITSTATUS( int status ) { return ( status & 0xFF00 ) >> 8; }
60 extern (D) int WIFCONTINUED( int status ) { return status == __W_CONTINUED; }
61 extern (D) bool WIFEXITED( int status ) { return __WTERMSIG( status ) == 0; }
62 extern (D) bool WIFSIGNALED( int status )
63 {
64 return ( cast(byte) ( ( status & 0x7F ) + 1 ) >> 1 ) > 0;
65 }
66 extern (D) bool WIFSTOPPED( int status ) { return ( status & 0xFF ) == 0x7F; }
67 extern (D) int WSTOPSIG( int status ) { return WEXITSTATUS( status ); }
68 extern (D) int WTERMSIG( int status ) { return status & 0x7F; }
69 }
70 else version( OSX )
71 {
72 enum WNOHANG = 1;
73 enum WUNTRACED = 2;
74
75 private
76 {
77 enum _WSTOPPED = 0177;
78 }
79
80 extern (D) int _WSTATUS(int status) { return (status & 0177); }
81 extern (D) int WEXITSTATUS( int status ) { return (status >> 8); }
82 extern (D) int WIFCONTINUED( int status ) { return status == 0x13; }
83 extern (D) bool WIFEXITED( int status ) { return _WSTATUS(status) == 0; }
84 extern (D) bool WIFSIGNALED( int status )
85 {
86 return _WSTATUS( status ) != _WSTOPPED && _WSTATUS( status ) != 0;
87 }
88 extern (D) bool WIFSTOPPED( int status ) { return _WSTATUS( status ) == _WSTOPPED; }
89 extern (D) int WSTOPSIG( int status ) { return status >> 8; }
90 extern (D) int WTERMSIG( int status ) { return _WSTATUS( status ); }
91 }
92 else version( freebsd )
93 {
94 enum WNOHANG = 1;
95 enum WUNTRACED = 2;
96 enum WCONTINUED = 4;
97
98 private
99 {
100 enum _WSTOPPED = 0177;
101 }
102
103 extern (D) int _WSTATUS(int status) { return (status & 0177); }
104 extern (D) int WEXITSTATUS( int status ) { return (status >> 8); }
105 extern (D) int WIFCONTINUED( int status ) { return status == 0x13; }
106 extern (D) bool WIFEXITED( int status ) { return _WSTATUS(status) == 0; }
107 extern (D) bool WIFSIGNALED( int status )
108 {
109 return _WSTATUS( status ) != _WSTOPPED && _WSTATUS( status ) != 0;
110 }
111 extern (D) bool WIFSTOPPED( int status ) { return _WSTATUS( status ) == _WSTOPPED; }
112 extern (D) int WSTOPSIG( int status ) { return status >> 8; }
113 extern (D) int WTERMSIG( int status ) { return _WSTATUS( status ); }
114 }
115 else
116 {
117 static assert( false );
118 }
119
120 pid_t wait(int*);
121 pid_t waitpid(pid_t, int*, int);
122
123 //
124 // XOpen (XSI)
125 //
126 /*
127 WEXITED
128 WSTOPPED
129 WCONTINUED
130 WNOHANG
131 WNOWAIT
132
133 enum idtype_t
134 {
135 P_ALL,
136 P_PID,
137 P_PGID
138 }
139
140 int waitid(idtype_t, id_t, siginfo_t*, int);
141 */