// ensurePidfd initializes the PidFD field in sysAttr if it is not already set. // It returns the original or modified SysProcAttr struct and a flag indicating // whether the PidFD should be duplicated before using. func ensurePidfd(sysAttr *syscall.SysProcAttr) (*syscall.SysProcAttr, bool) { … } // getPidfd returns the value of sysAttr.PidFD (or its duplicate if needDup is // set) and a flag indicating whether the value can be used. func getPidfd(sysAttr *syscall.SysProcAttr, needDup bool) (uintptr, bool) { … } func pidfdFind(pid int) (uintptr, error) { … } const _P_PIDFD … func (p *Process) pidfdWait() (*ProcessState, error) { … } func (p *Process) pidfdSendSignal(s syscall.Signal) error { … } func pidfdWorks() bool { … } var checkPidfdOnce … // checkPidfd checks whether all required pidfd-related syscalls work. This // consists of pidfd_open and pidfd_send_signal syscalls, waitid syscall with // idtype of P_PIDFD, and clone(CLONE_PIDFD). // // Reasons for non-working pidfd syscalls include an older kernel and an // execution environment in which the above system calls are restricted by // seccomp or a similar technology. func checkPidfd() error { … } // Provided by syscall. // //go:linkname checkClonePidfd func checkClonePidfd() error // Provided by runtime. // //go:linkname ignoreSIGSYS func ignoreSIGSYS() //go:linkname restoreSIGSYS func restoreSIGSYS()