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 <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2025-01-15 18:37:09 -08:00
parent 8fbdb7e78e
commit 4b87c7d4fd

View File

@@ -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
}