From 4b87c7d4fd7d8f1de1a89f79491504781b0077d8 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 15 Jan 2025 18:37:09 -0800 Subject: [PATCH] Fixups for newProcess 1. Pass an argument as a pointer rather than copying the whole structure. It was a pointer initially, but this has changed in commit b2d9d996 without giving a reason why. 2. The newProcess description was added by commit 9fac18329 (yes, the very first one) and hasn't changed since. As of commit 29b139f7, the part of it which says "and stdio from the current process" is no longer valid. Remove it, and while at it, rewrite the description entirely. Signed-off-by: Kir Kolyshkin --- utils_linux.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/utils_linux.go b/utils_linux.go index 724d6bb7073..c13ed585bfa 100644 --- a/utils_linux.go +++ b/utils_linux.go @@ -43,9 +43,8 @@ func getDefaultImagePath() string { return filepath.Join(cwd, "checkpoint") } -// newProcess returns a new libcontainer Process with the arguments from the -// spec and stdio from the current process. -func newProcess(p specs.Process) (*libcontainer.Process, error) { +// newProcess converts [specs.Process] to [libcontainer.Process]. +func newProcess(p *specs.Process) (*libcontainer.Process, error) { lp := &libcontainer.Process{ Args: p.Args, Env: p.Env, @@ -221,7 +220,7 @@ func (r *runner) run(config *specs.Process) (int, error) { if err = r.checkTerminal(config); err != nil { return -1, err } - process, err := newProcess(*config) + process, err := newProcess(config) if err != nil { return -1, err }