...
1
2
3
4
5 package unix
6
7 import (
8 "syscall"
9 )
10
11 const is64bit = ^uint(0) >> 63
12
13
14
15
16
17
18 type SiginfoChild struct {
19 Signo int32
20 siErrnoCode
21 _ [is64bit]int32
22
23
24
25 Pid int32
26 Uid uint32
27 Status int32
28
29
30 _ [128 - (6+is64bit)*4]byte
31 }
32
33 const (
34
35 _CLD_EXITED int32 = 1
36 _CLD_KILLED = 2
37 _CLD_DUMPED = 3
38 _CLD_TRAPPED = 4
39 _CLD_STOPPED = 5
40 _CLD_CONTINUED = 6
41
42
43 core = 0x80
44 stopped = 0x7f
45 continued = 0xffff
46 )
47
48
49
50 func (s *SiginfoChild) WaitStatus() (ws syscall.WaitStatus) {
51 switch s.Code {
52 case _CLD_EXITED:
53 ws = syscall.WaitStatus(s.Status << 8)
54 case _CLD_DUMPED:
55 ws = syscall.WaitStatus(s.Status) | core
56 case _CLD_KILLED:
57 ws = syscall.WaitStatus(s.Status)
58 case _CLD_TRAPPED, _CLD_STOPPED:
59 ws = syscall.WaitStatus(s.Status<<8) | stopped
60 case _CLD_CONTINUED:
61 ws = continued
62 }
63 return
64 }
65
View as plain text