-
Notifications
You must be signed in to change notification settings - Fork 136
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 is left scrambled when the app exits #247
Comments
Hi @alessio, thank you for sharing the link to Thank you for reporting this, I agree that it would be ideal if the terminal is correctly returned into the CLI mode even after unexpected crashes. I have a request if I may. Before we deep dive into https://github.com/mum4k/termdash/wiki/Tcell-API And an example of use is in the termdash/termdashdemo/termdashdemo.go Lines 487 to 490 in 2a7dafa
There is a chance that the cleanup will just work with Please let me know what you find out. |
Hey @mum4k - thanks for taking the time!
|
Thank you @alessio for giving I will look into it and try to identify some improvement. Once we know how to perform a correct cleanup, we can use Go's recover functionality to catch a panic and recover the terminal before finally crashing. |
@alessio, after looking at this a bit more and reminding myself of how panic handling works in Go, I don't think we have a good solution available. At least not in the infrastructure layer provided by https://golang.org/ref/spec#Handling_panics While executing a function F, an explicit call to panic or a run-time panic terminates the execution of F. Any functions deferred by F are then executed as usual. Next, any deferred functions run by F's caller are run, and so on up to any deferred by the top-level function in the executing goroutine. At that point, the program is terminated and the error condition is reported, including the value of the argument to panic. This termination sequence is called panicking. To clean and reset the terminal correctly, we need to make sure the termdash/termdashdemo/termdashdemo.go Line 499 in 2a7dafa
My assumption is that the panics you are dealing with originate in a different goroutine than the one that defers the call to the close method. Based on the definition in the spec - only deferred functions in the panicking goroutine get executed, then the program terminates. Since in Go other goroutines have no means of affecting or catching a panic in a separate goroutine, no code in termdash can change this behavior. The best solution I can think of needs to be done in the code that uses termdash/termdashdemo/termdashdemo.go Line 528 in 2a7dafa
Please let me know if this helps or if you think there is a way how we can fix this in the infrastructure layer. |
Going to close this for now, but please feel free to reopen if you have further questions or ideas how to solve this at the termdash layer. |
Hi,
One of my colleagues has written a gorgeous terminal-based block explorer application using
termdash
: https://github.com/Tosch110/gexWhile testing his application, I've noticed that when the app crashes, the terminal is left in bad state - pretty much as described in this upstream bug nsf/termbox-go#182 (comment).
Generally, I'd love to restore the terminal state so that users can continue working in the same terminal session after my app exits.
Any advice would be greatly appreciated.
Thanks for considering.
The text was updated successfully, but these errors were encountered: