mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
libct: don't allow to start second init process
By definition, every container has only 1 init (i.e. PID 1) process. Apparently, libcontainer API supported running more than 1 init, and at least one tests mistakenly used it. Let's not allow that, erroring out if we already have init. Doing otherwise _probably_ results in some confusion inside the library. Fix two cases in libct/int which ran two inits inside a container. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -306,6 +306,9 @@ func (c *Container) start(process *Process) (retErr error) {
|
||||
return errors.New("can't start container with SkipDevices set")
|
||||
}
|
||||
if process.Init {
|
||||
if c.initProcessStartTime != 0 {
|
||||
return errors.New("container already has init process")
|
||||
}
|
||||
if err := c.createExecFifo(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -115,7 +115,6 @@ func testExecInRlimit(t *testing.T, userns bool) {
|
||||
// increase process rlimit higher than container rlimit to test per-process limit
|
||||
{Type: unix.RLIMIT_NOFILE, Hard: 1026, Soft: 1026},
|
||||
},
|
||||
Init: true,
|
||||
}
|
||||
err = container.Run(ps)
|
||||
ok(t, err)
|
||||
@@ -359,7 +358,6 @@ func TestExecInEnvironment(t *testing.T) {
|
||||
Stdin: buffers.Stdin,
|
||||
Stdout: buffers.Stdout,
|
||||
Stderr: buffers.Stderr,
|
||||
Init: true,
|
||||
}
|
||||
err = container.Run(process2)
|
||||
ok(t, err)
|
||||
|
||||
Reference in New Issue
Block a user