| 195 | } |
| 196 | |
| 197 | func (p *Process) poll() (exited bool, _ error) { |
| 198 | if !p.pidfd.IncRef() { |
| 199 | return false, fmt.Errorf("pidfd: file closed") |
| 200 | } |
| 201 | defer p.pidfd.DecRef() |
| 202 | |
| 203 | fds := []unix.PollFd{{Fd: int32(p.pidfd.FD()), Events: unix.POLLIN}} |
| 204 | _, err := unix.Poll(fds, -1) |
| 205 | if err == unix.EINTR { |
| 206 | return false, nil |
| 207 | } |
| 208 | if err != nil { |
| 209 | return false, err |
| 210 | } |
| 211 | |
| 212 | return fds[0].Revents&unix.POLLIN != 0, nil |
| 213 | } |
| 214 | |
| 215 | // Wait waits for the process to exit and cleans up resources in the end. |
| 216 | func (p *Process) Wait() error { |