-
Notifications
You must be signed in to change notification settings - Fork 926
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
Interactive shell session hangs on exit if a background command is running #12210
Comments
Reproduced and LXD debug log shows this after
And then when the
|
@MusicDin @mihalicyn I've been doing a fair bit of research and experimentation around this. The key problem is that when the shell exits with a background process that is still holding the pty open, but not producing output the any reads or polls on that pty will block. Currently we are using I have tried reintroducing the approach Christian used with I wanted to see if the approach Christian originally used with the I found two things out:
I'm pretty sure that the breakage between 1. and 2. is caused by 06ada13 because rather than closing Whoops, my bad. However I then looked at the earlier implementation in more detail to figure out how it worked and it dawned on me that really the "working" version in 4.0/stable wasn't really working properly either. It wasn't unblocking the blocked E.g. this is from
So even when it did work (as in return from What I have found that works is to specify a timeout on the Then we can check if the parent process (the shell) has exited the next time a read is requested and if it has, then don't even call My POC is here: This doesn't leak go routines and returns within 1s of the parent process exiting if there are silent background tasks running. |
Great investigation, Tom! |
@mihalicyn do you see any problem with keeping |
No, I don't. I'll take a look closer on your PR. |
Fixes canonical#12210 Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
…ntainer exec Fixes canonical#12210 Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
Fixes canonical#12210 Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
…ntainer exec Fixes canonical#12210 Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
Required information
Issue description
A shell session does not handle Ctrl+D properly and hangs if there is a background command running.
Steps to reproduce
Information to attach
dmesg
)lxc info NAME --show-log
)lxc config show NAME --expanded
)lxc monitor
while reproducing the issue)The text was updated successfully, but these errors were encountered: