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

save/restore TTY attributes in test suite #727

Merged
merged 1 commit into from
Sep 30, 2017

Conversation

rolandwalker
Copy link
Contributor

defending against a tig crash

@rolandwalker rolandwalker force-pushed the tty-attr-libtest branch 2 times, most recently from 56f7434 to 83f0b18 Compare August 18, 2017 11:30
@jonas
Copy link
Owner

jonas commented Sep 29, 2017

What's the motivation for this? Tests are not supposed to touch the TTY.

@rolandwalker
Copy link
Contributor Author

I believe the motivation is fairly covered in #725 (comment), but even without #725, there were some cases where a tig crash during tests left the TTY in a wrong state.

Ncurses may do some unexpected things to resolve conflicts: eg tig gives ncurses /dev/null for the third argument to newterm(), but then tig calls raw() and so on. And raw() must call ioctl(), which is only possible on an fd which refers to a device or special file (tty). raw() might be returning ENOTTY and we fail to check the return value.

But in at least some cases it seems that ncurses decides to muddle through with some undefined behavior. For example it switches to STDIN for wgetch() after being told that infd referred to /dev/null.

That is from memory, and I don't have the code in front of me, so some details may be wrong.

Feel free to decline the PR — it is just a bit of defensive driving. The explanation is for your interest.

@jonas
Copy link
Owner

jonas commented Sep 30, 2017

Ah, OK. Thanks for the explanation. Makes sense.

@jonas jonas merged commit 73e0f77 into jonas:master Sep 30, 2017
@rolandwalker rolandwalker deleted the tty-attr-libtest branch September 30, 2017 20:28
Repository owner deleted a comment from sampittibul Oct 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants