mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
libct: move killing logic to container.Signal
By default, the container has its own PID namespace, and killing (with SIGKILL) its init process from the parent PID namespace also kills all the other processes. Obviously, it does not work that way when the container is sharing its PID namespace with the host or another container, since init is no longer special (it's not PID 1). In this case, killing container's init will result in a bunch of other processes left running (and thus the inability to remove the cgroup). The solution to the above problem is killing all the container processes, not just init. The problem with the current implementation is, the killing logic is implemented in libcontainer's initProcess.wait, and thus only available to libcontainer users, but not the runc kill command (which uses nonChildProcess.kill and does not use wait at all). So, some workarounds exist: - func destroy(c *Container) calls signalAllProcesses; - runc kill implements -a flag. This code became very tangled over time. Let's simplify things by moving the killing all processes from initProcess.wait to container.Signal, and documents the new behavior. In essence, this also makes `runc kill` to automatically kill all container processes when the container does not have its own PID namespace. Document that as well. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
+2
-2
@@ -18,8 +18,8 @@ to list available signals.
|
||||
# OPTIONS
|
||||
**--all**|**-a**
|
||||
: Send the signal to all processes inside the container, rather than
|
||||
the container's init only. This option is useful when the container does not
|
||||
have its own PID namespace.
|
||||
the container's init only. This option is implied when the _signal_ is **KILL**
|
||||
and the container does not have its own PID namespace.
|
||||
|
||||
: When this option is set, no error is returned if the container is stopped
|
||||
or does not exist.
|
||||
|
||||
Reference in New Issue
Block a user