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

Function setupPidfdSocket

utils_linux.go:420–445  ·  view source on GitHub ↗
(process *libcontainer.Process, sockpath string)

Source from the content-addressed store, hash-verified

418}
419
420func setupPidfdSocket(process *libcontainer.Process, sockpath string) (_clean func(), _ error) {
421 linux530 := kernelversion.KernelVersion{Kernel: 5, Major: 3}
422 ok, err := kernelversion.GreaterEqualThan(linux530)
423 if err != nil {
424 return nil, err
425 }
426 if !ok {
427 return nil, fmt.Errorf("--pidfd-socket requires >= v5.3 kernel")
428 }
429
430 conn, err := net.Dial("unix", sockpath)
431 if err != nil {
432 return nil, fmt.Errorf("failed to dail %s: %w", sockpath, err)
433 }
434
435 socket, err := conn.(*net.UnixConn).File()
436 if err != nil {
437 conn.Close()
438 return nil, fmt.Errorf("failed to dup socket: %w", err)
439 }
440
441 process.PidfdSocket = socket
442 return func() {
443 conn.Close()
444 }, nil
445}
446
447func maybeLogCgroupWarning(op string, err error) {
448 if errors.Is(err, fs.ErrPermission) {

Callers 1

runMethod · 0.85

Calls 3

GreaterEqualThanFunction · 0.92
FileMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…