mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
add ErrCgroupNotExist
For some rootless container, runc has no access to cgroup, But the container is still running. So we should return the `ErrNotRunning` and `ErrCgroupNotExist` error seperatlly. Signed-off-by: lifubang <lifubang@acmcoder.com>
This commit is contained in:
@@ -394,6 +394,11 @@ func (c *Container) Signal(s os.Signal) error {
|
||||
// https://github.com/opencontainers/runc/pull/4395#pullrequestreview-2291179652
|
||||
return c.signal(s)
|
||||
}
|
||||
// For not rootless container, if there is no init process and no cgroup,
|
||||
// it means that the container is not running.
|
||||
if errors.Is(err, ErrCgroupNotExist) && !c.hasInit() {
|
||||
err = ErrNotRunning
|
||||
}
|
||||
return fmt.Errorf("unable to kill all processes: %w", err)
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -10,4 +10,5 @@ var (
|
||||
ErrRunning = errors.New("container still running")
|
||||
ErrNotRunning = errors.New("container not running")
|
||||
ErrNotPaused = errors.New("container not paused")
|
||||
ErrCgroupNotExist = errors.New("cgroup not exist")
|
||||
)
|
||||
|
||||
@@ -695,11 +695,9 @@ func setupPersonality(config *configs.Config) error {
|
||||
|
||||
// signalAllProcesses freezes then iterates over all the processes inside the
|
||||
// manager's cgroups sending the signal s to them.
|
||||
//
|
||||
// signalAllProcesses returns ErrNotRunning when the cgroup does not exist.
|
||||
func signalAllProcesses(m cgroups.Manager, s unix.Signal) error {
|
||||
if !m.Exists() {
|
||||
return ErrNotRunning
|
||||
return ErrCgroupNotExist
|
||||
}
|
||||
// Use cgroup.kill, if available.
|
||||
if s == unix.SIGKILL {
|
||||
|
||||
Reference in New Issue
Block a user