mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Fix and refactor init args
1. According to docs of Cmd.Path and Cmd.Args from package "os/exec": Path is the path of the command to run. Args holds command line arguments, including the command as Args[0]. We have mixed usage of args. In InitPath(), InitArgs only take arguments, in InitArgs(), InitArgs including the command as Args[0]. This is confusing. 2. InitArgs() already have the ability to configure a LinuxFactory with the provided absolute path to the init binary and arguements as InitPath() does. 3. exec.Command() will take care of serching executable path. 4. The default "/proc/self/exe" instead of os.Args[0] is passed to InitArgs in order to allow relative path for the runC binary. Signed-off-by: Yang Hongyang <imhy.yang@gmail.com>
This commit is contained in:
@@ -35,7 +35,6 @@ type linuxContainer struct {
|
||||
root string
|
||||
config *configs.Config
|
||||
cgroupManager cgroups.Manager
|
||||
initPath string
|
||||
initArgs []string
|
||||
initProcess parentProcess
|
||||
initProcessStartTime string
|
||||
@@ -308,10 +307,7 @@ func (c *linuxContainer) newParentProcess(p *Process, doInit bool) (parentProces
|
||||
}
|
||||
|
||||
func (c *linuxContainer) commandTemplate(p *Process, childPipe, rootDir *os.File) (*exec.Cmd, error) {
|
||||
cmd := &exec.Cmd{
|
||||
Path: c.initPath,
|
||||
Args: c.initArgs,
|
||||
}
|
||||
cmd := exec.Command(c.initArgs[0], c.initArgs[1:]...)
|
||||
cmd.Stdin = p.Stdin
|
||||
cmd.Stdout = p.Stdout
|
||||
cmd.Stderr = p.Stderr
|
||||
|
||||
Reference in New Issue
Block a user