Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[1.4] libct: close child fds on prepareCgroupFD error#4936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
libct: refactor setnsProcess.start
Factor startWithCgroupFD out of start to reduce the start complexity.This also implements a more future-proof way of calling p.comm.closeChild.Co-authored-by: lifubang <lifubang@acmcoder.com>Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>(cherry picked from commit871052b)Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
  • Loading branch information
@kolyshkin@lifubang@cyphar
2 people authored andcyphar committedOct 15, 2025
commit42b405d59807d7782c35a64a21cb42011f5f4456
30 changes: 18 additions & 12 deletionslibcontainer/process_linux.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -353,32 +353,38 @@ func (p *setnsProcess) prepareCgroupFD() (*os.File, error) {
return fd, nil
}

func (p *setnsProcess) start() (retErr error) {
defer p.comm.closeParent()
// startWithCgroupFD starts a process via clone3 with CLONE_INTO_CGROUP,
// with a fallback if it fails (e.g. not available).
func (p *setnsProcess) startWithCgroupFD() error {
// Close the child side of the pipes.
defer p.comm.closeChild()

fd, err := p.prepareCgroupFD()
if err != nil {
p.comm.closeChild()
return err
}

// Get the "before" value of oom kill count.
oom, _ := p.manager.OOMKillCount()

err = p.startWithCPUAffinity()
if fd != nil {
fd.Close()
deferfd.Close()
}

err = p.startWithCPUAffinity()
if err != nil && p.cmd.SysProcAttr.UseCgroupFD {
logrus.Debugf("exec with CLONE_INTO_CGROUP failed: %v; retrying without", err)
// SysProcAttr.CgroupFD is never used when UseCgroupFD is unset.
p.cmd.SysProcAttr.UseCgroupFD = false
err = p.startWithCPUAffinity()
}

// Close the child-side of the pipes (controlled by child).
p.comm.closeChild()
if err != nil {
return err
}

func (p *setnsProcess) start() (retErr error) {
defer p.comm.closeParent()

// Get the "before" value of oom kill count.
oom, _ := p.manager.OOMKillCount()

if err := p.startWithCgroupFD(); err != nil {
return fmt.Errorf("error starting setns process: %w", err)
}

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp