-
Notifications
You must be signed in to change notification settings - Fork 128
add Wait() for nslistener process to avoid zombies #433
Conversation
supervisor/hyperpod.go
Outdated
| go func() { | ||
| hp.nslistener.cmd.Process.Kill() | ||
| }() | ||
| if err := hp.nslistener.cmd.Process.Signal(syscall.Signal(0)); err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems strange that Process.Signal() and Process.Kill() are called at the same time.
if Process.Kill() is required when Process.Signal() is ignored by the target, I think a timer is also needed before Process.Kill().
supervisor/hyperpod.go
Outdated
| hp.nslistener.cmd.Process.Kill() | ||
| }() | ||
| if err := hp.nslistener.cmd.Process.Signal(syscall.Signal(0)); err == nil { | ||
| hp.nslistener.cmd.Wait() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think cmd.Wait() should be called unconditionally, WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The signal(0) was just to ensure the process is really alive to prevent runtime panic on cmd.Wait.
Do you prefer it like this?
- hp.nslistener.cmd.Process.Kill()
+ go func() {
+ time.Sleep(time.Second*1)
+ hp.nslistener.cmd.Process.Kill()
+ }()
+ hp.nslistener.cmd.Wait()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use time.AfterFunc()
"if hp.nslistener != nil" ensures the process is/was launched
|
I like something like this hp.nslistener.cmd.Process.Signal(syscall.SIGTERM)
timer := time.AfterFunc(time.Second*1, func() { hp.nslistener.cmd.Process.Kill() })
hp.nslistener.cmd.Wait()
timer.Stop()or just kill&wait, no timer&signal |
|
i don't get the difference. Please fix it as you like. Thanks. |
|
there is no Signal() in your code, so it will always take 1 seconds to stop the nslistener |
This patch adds a missing cmd.Wait() to wait for process completion of containerd-nslistener. Without the wait every container leaves a defunct process. This is required since #430 removed the global SIGCHILD handler to avoid runtime panics. Signed-off-by: Peter Morjan <peter.morjan@de.ibm.com>
|
@pmorjan runv cli is being improved continuously and had just been refactored #537 . As a result, it seams that the changes in this pr is outdated. In the new code, this problem is fixed by this code: defer func() {
if err != nil {
cmd.Process.Kill()
}
cmd.Wait()
}()Thank you for your contribution. |
This patch adds a missing cmd.Wait() to wait for process completion
of containerd-nslistener. Without the wait every container leaves
a defunct process. This is required since #430 removed the global
SIGCHILD handler to avoid runtime panics.
Signed-off-by: Peter Morjan peter.morjan@de.ibm.com