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

Method startWithCgroupFD

libcontainer/process_linux.go:432–456  ·  view source on GitHub ↗

startWithCgroupFD starts a process via clone3 with CLONE_INTO_CGROUP, with a fallback if it fails (e.g. not available).

()

Source from the content-addressed store, hash-verified

430// startWithCgroupFD starts a process via clone3 with CLONE_INTO_CGROUP,
431// with a fallback if it fails (e.g. not available).
432func (p *setnsProcess) startWithCgroupFD() error {
433 // Close the child side of the pipes.
434 defer p.comm.closeChild()
435
436 fd, err := p.prepareCgroupFD()
437 if err != nil {
438 return err
439 }
440 if fd != nil {
441 defer fd.Close()
442 }
443
444 cmdCopy := cloneCmd(p.cmd)
445 err = p.startWithCPUAffinity()
446 if err != nil && p.cmd.SysProcAttr.UseCgroupFD {
447 logrus.Debugf("exec with CLONE_INTO_CGROUP failed: %v; retrying without", err)
448 // SysProcAttr.CgroupFD is never used when UseCgroupFD is unset.
449 cmdCopy.SysProcAttr.UseCgroupFD = false
450 // Must not reuse exec.Cmd.
451 p.cmd = cmdCopy
452 err = p.startWithCPUAffinity()
453 }
454
455 return err
456}
457
458func (p *setnsProcess) start() (retErr error) {
459 defer p.comm.closeParent()

Callers 1

startMethod · 0.95

Calls 5

prepareCgroupFDMethod · 0.95
startWithCPUAffinityMethod · 0.95
cloneCmdFunction · 0.85
closeChildMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected