Skip to content
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

A more reliable means of avoiding errors caused by stdin or stdout redirection #3563

Open
dodexahedron opened this issue Jun 25, 2024 · 0 comments
Labels
bug design Issues regarding Terminal.Gui design (bugs, guidelines, debates, etc...) Linux MacOS v1 For Issues & PRs targetting v1.x v2 For discussions, issues, etc... relavant for v2 Windows
Milestone

Comments

@dodexahedron
Copy link
Collaborator

Something to deal with at some point, to handle the issue discussed in the linked conversation:

Something I brought up in an unrelated issue provides a solution here.

When Console.IsInputRedirected is true, that is an indicator the stream is not a tty and is actually exactly how all current operating systems define what it means to be a tty.

Not being a tty is what causes this problem. The other things are just symptoms.

It's not something we can fix, since being a tty is required to do what TG does.

But, we can reliably avoid that exception by checking Console.IsInputRedirected and Console.IsOutputRedirected, where each is respectively relevant, and either perform graceful back-off or shutdown in Terminal.Gui or throw a meaningful and specific exception.

Unfortunately, there's no automatic means of being notified that redirection happened, so all you can do is poll those properties.

All platforms use the C99 standard method of determining if a stream is a tty, too, so it's an operation that can and probably should be handled in the base ConsoleDriver class.

Originally posted by @dodexahedron in #3519 (comment)

@dodexahedron dodexahedron added bug Windows MacOS Linux design Issues regarding Terminal.Gui design (bugs, guidelines, debates, etc...) v2 For discussions, issues, etc... relavant for v2 v1 For Issues & PRs targetting v1.x labels Jun 25, 2024
@dodexahedron dodexahedron added this to the V2 Alpha milestone Jun 25, 2024
@dodexahedron dodexahedron moved this to 🆕 Not Triaged in Terminal.Gui V2 Initial Release Jun 25, 2024
@tig tig modified the milestones: V2 Alpha, V2 Beta, v2 Release Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug design Issues regarding Terminal.Gui design (bugs, guidelines, debates, etc...) Linux MacOS v1 For Issues & PRs targetting v1.x v2 For discussions, issues, etc... relavant for v2 Windows
Projects
Status: 🆕 Not Triaged
Development

No branches or pull requests

2 participants