mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
libct: signalAllProcesses: remove child reaping
There are two very distinct usage scenarios for signalAllProcesses:
* when used from the runc binary ("runc kill" command), the processes
that it kills are not the children of "runc kill", and so calling
wait(2) on each process is totally useless, as it will return ECHLD;
* when used from a program that have created the container (such as
libcontainer/integration test suite), that program can and should call
wait(2), not the signalling code.
So, the child reaping code is totally useless in the first case, and
should be implemented by the program using libcontainer in the second
case. I was not able to track down how this code was added, my best
guess is it happened when this code was part of dockerd, which did not
have a proper child reaper implemented at that time.
Remove it, and add a proper documentation piece.
Change the integration test accordingly.
PS the first attempt to disable the child reaping code in
signalAllProcesses was made in commit bb912eb00c, which used a
questionable heuristic to figure out whether wait(2) should be called.
This heuristic worked for a particular use case, but is not correct in
general.
While at it:
- simplify signalAllProcesses to use unix.Kill;
- document (container).Signal.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -1373,7 +1373,7 @@ func TestPIDHostInitProcessWait(t *testing.T) {
|
||||
|
||||
process1 := &libcontainer.Process{
|
||||
Cwd: "/",
|
||||
Args: []string{"sleep", "100"},
|
||||
Args: []string{"sleep", "1h"},
|
||||
Env: standardEnvironment,
|
||||
Init: true,
|
||||
}
|
||||
@@ -1382,7 +1382,7 @@ func TestPIDHostInitProcessWait(t *testing.T) {
|
||||
|
||||
process2 := &libcontainer.Process{
|
||||
Cwd: "/",
|
||||
Args: []string{"sleep", "100"},
|
||||
Args: []string{"sleep", "1h"},
|
||||
Env: standardEnvironment,
|
||||
Init: false,
|
||||
}
|
||||
@@ -1397,10 +1397,11 @@ func TestPIDHostInitProcessWait(t *testing.T) {
|
||||
t.Fatal("expected Wait to indicate failure")
|
||||
}
|
||||
|
||||
// The non-init process must've been killed.
|
||||
err = process2.Signal(syscall.Signal(0))
|
||||
if err == nil || err.Error() != "no such process" {
|
||||
t.Fatalf("expected process to have been killed: %v", err)
|
||||
// The non-init process must've also been killed. If not,
|
||||
// the test will time out.
|
||||
_, err = process2.Wait()
|
||||
if err == nil {
|
||||
t.Fatal("expected Wait to indicate failure")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user