-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
Terminal resize causes wait to exit #1067
Comments
Ah I can reproduce this, thank you ... There was another bug related to SIGWINCH, but I don't remember offhand which one. |
OK there is actually an architecture issue here -- Oil registers a handler for In contrast, bash relies on GNU readline to listen for SIGWINCH. And it ENABLES and disables the handler when entering and exiting We should probably do the same thing. And this is basically the same bug as #292 with Thanks again for the report! |
Although I also wonder if bash is incorrect because of this? What happens if you do
Hm no it seems alright. So I guess it must recompute it every time it prints the prompt |
The line editor is the only thing that needs to know the width, so I think we should let it handle the problem. Unfortunately GNU readline is not what we want, but that's a separate issue. This means the core/comp_ui.py now doesn't adjust when the window is resized. But that dosn't make the shell unusuable. We should revisit it later. Apparently fish and zsh do something different anyway -- they REDRAW on SIGWINCH. They don't merely update the width. - Added a test in test/interactive.py. - Addresses #1067
OK I just made OSH ignore SIGWINCH, which is what most shells do. I still want to figure out what to do with Thanks for the report! |
Related to oils-for-unix#1067. This commit fixes a problem with the width not being updated in the completion UI as a side effect of ignoring SIGWINCH.
That seems to solve the problem, thank you. I'm still hesitant to close this since, as you mentioned, 3ab4e69 causes the completion UI to break. So, I experimented a little and tried to fix the completion issue: 3e4c8dd That seems to be working fine for me. It just registers a signal handler when it asks for user input and then unregisters it when it tries to execute a command. This might be a little too much brute-force since (AFAIK) it's basically unnecessary to unregister the signal handler if the command is not a builtin. Not sure if that would break anything else. |
Hmm yeah this is not bad... I can't see an obvious reason this would break. I was worried about it not being exception safe but I think all the exceptions are caught. Ahhh one problem might be shell completion plugins run when you hit TAB. That happens within the area where SIGWINCH is enabled. In that case the I realize that punting on the whole issue seems lame, but the core issue is that the current approach is not that great because of #257 either. That is, I'd rather have a line editing experience like zsh or fish in Oil, but that appears impossible given that we use GNU readline. I think the author of ble.sh concurs with this... (this is a line editor in pure bash!) And as mentioned, zsh and fish appear to actually redraw the screen on SIGWINCH! They have to keep track of a lot of state that's not exposed by GNU readline. I think what I'm leaning toward is making the default experience like bash, but then having an option to try to keep the prompt stable like zsh/fish? Another possibility is to ask GNU readline to expose LINES and COLUMNS to us. Maybe that is what bash does? I will look. |
OSH now queries this state, instead of trying to keep track of it ourselves. So OSH behaves like bash and other shells here: - If trap 'echo X' SIGWINCH, then SIGWINCH will interrupt the wait builtin. - Otherwise it is ignored. We take care to only enable the SIGWINCH handler inside call_readline(), when shell code isn't running. When the TAB completion callback is invoked, we do the reverse: we disable our SIGWINCH tracking. So we can lose some resizes, but this is what other shells do. TODO: Test this out a bit more. Addresses #1067.
OK I mostly fixed this:
BUT:
Related: this area is very hairy in bash too ... So I feel better about butting my head against it :-/
|
Also I found #1080 , which is related Related question: why are
I guess this is because read can run traps and continue to do its job ... it sorta makes sense. |
Doh this might have actually been a bug with Oh well this actually motivated some cleanup and simplification |
It's now tested in BTW this issue caused me to pull on a VERY LONG THREAD of fixing interactive shell and signal behavior, which is still ongoing, but it is going to be good. If interested there is a ton on Zulip: Thanks for the nudge in the right direction :) |
Hm there was spurious fix for #1067 here ... what's the right fix?
This is the same bug as #1067, but with 'wait -n' instead of 'wait'. I changed it to loop until one fewer job is running. This also had the side effect of fixing another test case, so there's only one failure now! - Clean up 'wait -n' spec tests.
Done in 0.9.7: https://www.oilshell.org/blog/2022/01/notes-themes.html Thanks again for the report, this ended up being very productive, as I described in the blog post! Let me know if you see any other issues |
It looks like
wait
doesn't behave correctly when the terminal window it runs in gets resized.Example in
oil
:Setting a signal handler for
SIGWINCH
before running the above code shows that it attempts to run the signal handler (without any output?) and immediately kills the child process:The same happens with
osh
regardless of whethererrexit
is set:In the case of
osh
, it doesn't seem to output any information outside of whatset -x
provides.I assume this is not intended behavior since it's not consistent with bash.
I've tested this on the most recent release (0.9.6) and a build straight from the master branch and the behavior is the same.
The text was updated successfully, but these errors were encountered: