startWithCgroupFD starts a process via clone3 with CLONE_INTO_CGROUP, with a fallback if it fails (e.g. not available).
()
| 430 | // startWithCgroupFD starts a process via clone3 with CLONE_INTO_CGROUP, |
| 431 | // with a fallback if it fails (e.g. not available). |
| 432 | func (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 | |
| 458 | func (p *setnsProcess) start() (retErr error) { |
| 459 | defer p.comm.closeParent() |
no test coverage detected