comparison tango/tango/stdc/posix/sys/wait.d @ 132:1700239cab2e trunk

[svn r136] MAJOR UNSTABLE UPDATE!!! Initial commit after moving to Tango instead of Phobos. Lots of bugfixes... This build is not suitable for most things.
author lindquist
date Fri, 11 Jan 2008 17:57:40 +0100
parents
children
comparison
equal deleted inserted replaced
131:5825d48b27d1 132:1700239cab2e
1 /**
2 * D header file for POSIX.
3 *
4 * Copyright: Public Domain
5 * License: Public Domain
6 * Authors: Sean Kelly
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8 */
9 module tango.stdc.posix.sys.wait;
10
11 public import tango.stdc.posix.sys.types; // for id_t, pid_t
12 public import tango.stdc.posix.signal; // for siginfo_t (XSI)
13 //public import tango.stdc.posix.resource; // for rusage (XSI)
14
15 extern (C):
16
17 //
18 // Required
19 //
20 /*
21 WNOHANG
22 WUNTRACED
23
24 WEXITSTATUS
25 WIFCONTINUED
26 WIFEXITED
27 WIFSIGNALED
28 WIFSTOPPED
29 WSTOPSIG
30 WTERMSIG
31
32 pid_t wait(int*);
33 pid_t waitpid(pid_t, int*, int);
34 */
35
36 version( linux )
37 {
38 const WNOHANG = 1;
39 const WUNTRACED = 2;
40
41 private
42 {
43 const __W_CONTINUED = 0xFFFF;
44
45 extern (D) int __WTERMSIG( int status ) { return status & 0x7F; }
46 }
47
48 //
49 // NOTE: These macros assume __USE_BSD is not defined in the relevant
50 // C headers as the parameter definition there is different and
51 // much more complicated.
52 //
53 extern (D) int WEXITSTATUS( int status ) { return ( status & 0xFF00 ) >> 8; }
54 extern (D) int WIFCONTINUED( int status ) { return status == __W_CONTINUED; }
55 extern (D) bool WIFEXITED( int status ) { return __WTERMSIG( status ) == 0; }
56 extern (D) bool WIFSIGNALED( int status )
57 {
58 return ( cast(byte) ( ( status & 0x7F ) + 1 ) >> 1 ) > 0;
59 }
60 extern (D) bool WIFSTOPPED( int status ) { return ( status & 0xFF ) == 0x7F; }
61 extern (D) int WSTOPSIG( int status ) { return WEXITSTATUS( status ); }
62 extern (D) int WTERMSIG( int status ) { return status & 0x7F; }
63 }
64 else version( darwin )
65 {
66 const WNOHANG = 1;
67 const WUNTRACED = 2;
68
69 private
70 {
71 const _WSTOPPED = 0177;
72 }
73
74 extern (D) int _WSTATUS(int status) { return (status & 0177); }
75 extern (D) int WEXITSTATUS( int status ) { return (status >> 8); }
76 extern (D) int WIFCONTINUED( int status ) { return status == 0x13; }
77 extern (D) bool WIFEXITED( int status ) { return _WSTATUS(status) == 0; }
78 extern (D) bool WIFSIGNALED( int status )
79 {
80 return _WSTATUS( status ) != _WSTOPPED && _WSTATUS( status ) != 0;
81 }
82 extern (D) bool WIFSTOPPED( int status ) { return _WSTATUS( status ) == _WSTOPPED; }
83 extern (D) int WSTOPSIG( int status ) { return status >> 8; }
84 extern (D) int WTERMSIG( int status ) { return _WSTATUS( status ); }
85 }
86 else
87 {
88 static assert( false );
89 }
90
91 pid_t wait(int*);
92 pid_t waitpid(pid_t, int*, int);
93
94 //
95 // XOpen (XSI)
96 //
97 /*
98 WEXITED
99 WSTOPPED
100 WCONTINUED
101 WNOHANG
102 WNOWAIT
103
104 enum idtype_t
105 {
106 P_ALL,
107 P_PID,
108 P_PGID
109 }
110
111 int waitid(idtype_t, id_t, siginfo_t*, int);
112 */