-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make sure console master tty is closed on task exit #11161
base: main
Are you sure you want to change the base?
Conversation
c448293
to
4dd66e1
Compare
d2728aa
to
dfc8bd6
Compare
dfc8bd6
to
8a238f6
Compare
ad49a39
to
e593ccd
Compare
@@ -276,6 +276,12 @@ func (p *Init) setExited(status int) { | |||
p.exited = time.Now() | |||
p.status = status | |||
p.Platform.ShutdownConsole(context.Background(), p.console) | |||
// We need to close the master tty here, in case of stdin, |
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 we can call p.console.Close()
during deleting.
containerd/cmd/containerd-shim-runc-v2/process/init.go
Lines 290 to 292 in a5aaa40
func (p *Init) delete(ctx context.Context) error { | |
waitTimeout(ctx, &p.wg, 2*time.Second) | |
err := p.runtime.Delete(ctx, p.id, nil) |
Before deleting task, containerd always drains IO first. It's safe to close console in that place.
For the line 283 about calling p.wg.Wait()
, I think it's unsafe to do that because SetExited
is called by background goroutine triggered by SIGCHILD. When init process exits, its children might hold IO so that p.wg.Wait()
will block until all its children exit. Check this issue #10094 for more details.
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.
Thanks @fuweid. That info really helped! I've made the suggested changes.
Signed-off-by: Henry Wang <[email protected]>
Signed-off-by: Henry Wang <[email protected]>
Fixes: #11160