New creates a new process with the given PID.
(global *global.Global, itab *socket.InodeTable, pid int)
| 40 | |
| 41 | // New creates a new process with the given PID. |
| 42 | func New(global *global.Global, itab *socket.InodeTable, pid int) (*Process, error) { |
| 43 | ret, _, errno := unix.Syscall(unix.SYS_PIDFD_OPEN, uintptr(pid), 0, 0) |
| 44 | if errno != 0 { |
| 45 | return nil, fmt.Errorf("pidfd_open %d: %w", pid, errno) |
| 46 | } |
| 47 | |
| 48 | pidfd := fd.NewFD(int(ret)) |
| 49 | defer pidfd.DecRef() |
| 50 | |
| 51 | return &Process{ |
| 52 | global: global, |
| 53 | itab: itab, |
| 54 | |
| 55 | PID: pid, |
| 56 | Exited: make(chan struct{}), |
| 57 | |
| 58 | pidfd: pidfd, |
| 59 | sockets: make(map[int]*socket.Socket), |
| 60 | }, nil |
| 61 | } |
| 62 | |
| 63 | func (p *Process) getEventTemplate() *event.Event { |
| 64 | if tmpl := p.tmpl.Load(); tmpl != nil { |
no test coverage detected