Skip to content

Commit

Permalink
Fixups for newProcess
Browse files Browse the repository at this point in the history
1. Pass an argument as a pointer rather than copying the whole structure.
   It was a pointer initially, but this has changed in commit b2d9d99
   without giving a reason why.

2. The newProcess description was added by commit 9fac183 (yes, the
   very first one) and hasn't changed since. As of commit 29b139f,
   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>
  • Loading branch information
kolyshkin committed Jan 16, 2025
1 parent 081091c commit bfae791
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions utils_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -218,7 +217,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
}
Expand Down

0 comments on commit bfae791

Please sign in to comment.