Skip to content

Commit

Permalink
refactor: make reexec args a slice
Browse files Browse the repository at this point in the history
  • Loading branch information
nixpig committed Dec 23, 2024
1 parent 63ad257 commit 693ca66
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions container/container_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/opencontainers/runtime-spec/specs-go"
)

func (c *Container) Init(reexec string, arg string) error {
func (c *Container) Init(reexecCmd string, reexecArgs []string) error {
if err := c.ExecHooks("createRuntime"); err != nil {
return fmt.Errorf("execute createRuntime hooks: %w", err)
}
Expand All @@ -25,7 +25,7 @@ func (c *Container) Init(reexec string, arg string) error {
return fmt.Errorf("execute createContainer hooks: %w", err)
}

cmd := exec.Command(reexec, []string{arg, c.ID()}...)
cmd := exec.Command(reexecCmd, append(reexecArgs, c.ID())...)

useTerminal := c.Spec.Process != nil &&
c.Spec.Process.Terminal &&
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func createCmd() *cobra.Command {
ConsoleSocket: consoleSocket,
PIDFile: pidFile,
ReexecCmd: "/proc/self/exe",
ReexecSubcmd: "reexec",
ReexecArgs: []string{"reexec"},
})
},
}
Expand Down
4 changes: 2 additions & 2 deletions internal/commands/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type CreateOpts struct {
ConsoleSocket string
PIDFile string
ReexecCmd string
ReexecSubcmd string
ReexecArgs []string
}

func Create(opts *CreateOpts) error {
Expand Down Expand Up @@ -44,5 +44,5 @@ func Create(opts *CreateOpts) error {
return fmt.Errorf("create container: %w", err)
}

return cntr.Init(opts.ReexecCmd, opts.ReexecSubcmd)
return cntr.Init(opts.ReexecCmd, opts.ReexecArgs)
}

0 comments on commit 693ca66

Please sign in to comment.