MCPcopy
hub / github.com/opencontainers/runc / setupPidfd

Function setupPidfd

libcontainer/init_linux.go:724–737  ·  view source on GitHub ↗

setupPidfd opens a process file descriptor of init process, and sends the file descriptor back to the socket.

(socket *os.File, initType string)

Source from the content-addressed store, hash-verified

722// setupPidfd opens a process file descriptor of init process, and sends the
723// file descriptor back to the socket.
724func setupPidfd(socket *os.File, initType string) error {
725 defer socket.Close()
726
727 pidFd, err := unix.PidfdOpen(os.Getpid(), 0)
728 if err != nil {
729 return fmt.Errorf("failed to pidfd_open: %w", err)
730 }
731
732 if err := cmsg.SendRawFd(socket, initType, uintptr(pidFd)); err != nil {
733 unix.Close(pidFd)
734 return fmt.Errorf("failed to send pidfd on socket: %w", err)
735 }
736 return unix.Close(pidFd)
737}

Callers 2

InitMethod · 0.85
InitMethod · 0.85

Calls 2

SendRawFdFunction · 0.92
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…