@@ -44,6 +44,8 @@ pub enum WaitStatus {
44
44
Exited ( pid_t , i8 ) ,
45
45
Signaled ( pid_t , Signal , bool ) ,
46
46
Stopped ( pid_t , Signal ) ,
47
+ #[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
48
+ PtraceEvent ( pid_t , Signal , c_int ) ,
47
49
Continued ( pid_t ) ,
48
50
StillAlive
49
51
}
@@ -52,6 +54,7 @@ pub enum WaitStatus {
52
54
target_os = "android" ) ) ]
53
55
mod status {
54
56
use sys:: signal:: Signal ;
57
+ use libc:: c_int;
55
58
56
59
pub fn exited ( status : i32 ) -> bool {
57
60
( status & 0x7F ) == 0
@@ -81,6 +84,10 @@ mod status {
81
84
Signal :: from_c_int ( ( status & 0xFF00 ) >> 8 ) . unwrap ( )
82
85
}
83
86
87
+ pub fn stop_additional ( status : i32 ) -> c_int {
88
+ ( status >> 16 ) as c_int
89
+ }
90
+
84
91
pub fn continued ( status : i32 ) -> bool {
85
92
status == 0xFFFF
86
93
}
@@ -184,7 +191,23 @@ fn decode(pid : pid_t, status: i32) -> WaitStatus {
184
191
} else if status:: signaled ( status) {
185
192
WaitStatus :: Signaled ( pid, status:: term_signal ( status) , status:: dumped_core ( status) )
186
193
} else if status:: stopped ( status) {
187
- WaitStatus :: Stopped ( pid, status:: stop_signal ( status) )
194
+ cfg_if ! {
195
+ if #[ cfg( any( target_os = "linux" , target_os = "android" ) ) ] {
196
+ fn decode_stopped( pid: pid_t, status: i32 ) -> WaitStatus {
197
+ let status_additional = status:: stop_additional( status) ;
198
+ if status_additional == 0 {
199
+ WaitStatus :: Stopped ( pid, status:: stop_signal( status) )
200
+ } else {
201
+ WaitStatus :: PtraceEvent ( pid, status:: stop_signal( status) , status:: stop_additional( status) )
202
+ }
203
+ }
204
+ } else {
205
+ fn decode_stopped( pid: pid_t, status: i32 ) -> WaitStatus {
206
+ WaitStatus :: Stopped ( pid, status:: stop_signal( status) )
207
+ }
208
+ }
209
+ }
210
+ decode_stopped ( pid, status)
188
211
} else {
189
212
assert ! ( status:: continued( status) ) ;
190
213
WaitStatus :: Continued ( pid)
0 commit comments