Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

root/trunk/tango/stdc/posix/sys/wait.d

Revision 4378, 4.5 kB (checked in by fawzi, 3 years ago)

opensolaris support, stremlined large file support

  • Property svn:mime-type set to text/x-dsrc
  • Property svn:eol-style set to native
Line 
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 private import tango.stdc.posix.config;
12 public import tango.stdc.posix.sys.types; // for id_t, pid_t
13 public import tango.stdc.posix.signal;    // for siginfo_t (XSI)
14 //public import tango.stdc.posix.resource; // for rusage (XSI)
15
16 extern (C):
17
18 //
19 // Required
20 //
21 /*
22 WNOHANG
23 WUNTRACED
24
25 WEXITSTATUS
26 WIFCONTINUED
27 WIFEXITED
28 WIFSIGNALED
29 WIFSTOPPED
30 WSTOPSIG
31 WTERMSIG
32
33 pid_t wait(int*);
34 pid_t waitpid(pid_t, int*, int);
35 */
36
37 version( linux )
38 {
39     const WNOHANG       = 1;
40     const WUNTRACED     = 2;
41
42     private
43     {
44         const __W_CONTINUED = 0xFFFF;
45
46         extern (D) int __WTERMSIG( int status ) { return status & 0x7F; }
47     }
48
49     //
50     // NOTE: These macros assume __USE_BSD is not defined in the relevant
51     //       C headers as the parameter definition there is different and
52     //       much more complicated.
53     //
54     extern (D) int  WEXITSTATUS( int status )  { return ( status & 0xFF00 ) >> 8;   }
55     extern (D) int  WIFCONTINUED( int status ) { return status == __W_CONTINUED;    }
56     extern (D) bool WIFEXITED( int status )    { return __WTERMSIG( status ) == 0;  }
57     extern (D) bool WIFSIGNALED( int status )
58     {
59         return ( cast(byte) ( ( status & 0x7F ) + 1 ) >> 1 ) > 0;
60     }
61     extern (D) bool WIFSTOPPED( int status )   { return ( status & 0xFF ) == 0x7F;  }
62     extern (D) int  WSTOPSIG( int status )     { return WEXITSTATUS( status );      }
63     extern (D) int  WTERMSIG( int status )     { return status & 0x7F;              }
64 }
65 else version( darwin )
66 {
67     const WNOHANG       = 1;
68     const WUNTRACED     = 2;
69
70     private
71     {
72         const _WSTOPPED = 0177;
73     }
74
75     extern (D) int _WSTATUS(int status)         { return (status & 0177);           }
76     extern (D) int  WEXITSTATUS( int status )   { return (status >> 8);             }
77     extern (D) int  WIFCONTINUED( int status )  { return status == 0x13;            }
78     extern (D) bool WIFEXITED( int status )     { return _WSTATUS(status) == 0;     }
79     extern (D) bool WIFSIGNALED( int status )
80     {
81         return _WSTATUS( status ) != _WSTOPPED && _WSTATUS( status ) != 0;
82     }
83     extern (D) bool WIFSTOPPED( int status )   { return _WSTATUS( status ) == _WSTOPPED; }
84     extern (D) int  WSTOPSIG( int status )     { return status >> 8;                     }
85     extern (D) int  WTERMSIG( int status )     { return _WSTATUS( status );              }
86 }
87 else version( freebsd )
88 {
89     const WNOHANG       = 1;
90     const WUNTRACED     = 2;
91     const WCONTINUED    = 4;
92
93     private
94     {
95         const _WSTOPPED = 0177;
96     }
97
98     extern (D) int _WSTATUS(int status)         { return (status & 0177);           }
99     extern (D) int  WEXITSTATUS( int status )   { return (status >> 8);             }
100     extern (D) int  WIFCONTINUED( int status )  { return status == 0x13;            }
101     extern (D) bool WIFEXITED( int status )     { return _WSTATUS(status) == 0;     }
102     extern (D) bool WIFSIGNALED( int status )
103     {
104         return _WSTATUS( status ) != _WSTOPPED && _WSTATUS( status ) != 0;
105     }
106     extern (D) bool WIFSTOPPED( int status )   { return _WSTATUS( status ) == _WSTOPPED; }
107     extern (D) int  WSTOPSIG( int status )     { return status >> 8;                     }
108     extern (D) int  WTERMSIG( int status )     { return _WSTATUS( status );              }
109 }
110 else version( solaris )
111 {  
112     const WCONTFLG      = 0177777;
113    
114     const WNOHANG       = 0100;
115     const WUNTRACED     = 0004;
116     const WCONTINUED    = 0010;
117    
118     extern (D) int  WWORD( int status )         { return (status & 0177777);            }
119     extern (D) int  WEXITSTATUS( int status )   { return (status >> 8) & 0xFF;          }
120     extern (D) int  WIFCONTINUED( int status )  { return WWORD(status) == WCONTFLG;     }
121     extern (D) bool WIFEXITED( int status )     { return (status & 0xFF) == 0;          }
122     extern (D) bool WIFSIGNALED( int status )   { return (status & 0xFF) > 0 && (status & 0xFF00) == 0; }
123     extern (D) bool WIFSTOPPED( int status )    { return (status & 0xFF) == 0177 && (status & 0xFF00) != 0; }
124     extern (D) int  WSTOPSIG( int status )      { return (status >> 8) & 0xFF;          }
125     extern (D) int  WTERMSIG( int status )      { return status & 0x7F;                 }
126 }
127 else
128 {
129     static assert( false );
130 }
131
132 pid_t wait(int*);
133 pid_t waitpid(pid_t, int*, int);
134
135 //
136 // XOpen (XSI)
137 //
138 /*
139 WEXITED
140 WSTOPPED
141 WCONTINUED
142 WNOHANG
143 WNOWAIT
144
145 enum idtype_t
146 {
147     P_ALL,
148     P_PID,
149     P_PGID
150 }
151
152 int waitid(idtype_t, id_t, siginfo_t*, int);
153 */
Note: See TracBrowser for help on using the browser.