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

Use blocking IO on a TTY if it can't be reopened #6660

Merged
merged 2 commits into from
Sep 5, 2018

Conversation

Timbus
Copy link
Contributor

@Timbus Timbus commented Sep 4, 2018

Should fix issue #6624

Kinda hard to test though. Doesn't seem to have any regressions at least.

@RX14
Copy link
Contributor

RX14 commented Sep 4, 2018

Probably cleaner to do

path = uninitialized UInt8[256]
ret = LibC.ttyname_r(fd, path, 256)
return new(fd: blocking: true) unless ret == 0

clone_fd = LibC.open(path, LibC::O_RDWR)
return new(fd: blocking: true) if clone_fd == -1

new(clone_fd).tap(&.close_on_exec = true)

@Sija
Copy link
Contributor

Sija commented Sep 4, 2018

@RX14 Your example calls are missing fd / clone_fd argument.

@ysbaddaden ysbaddaden added this to the 0.27.0 milestone Sep 5, 2018
@RX14 RX14 merged commit b697de0 into crystal-lang:master Sep 5, 2018
@RX14 RX14 added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib labels Sep 5, 2018
RX14 pushed a commit to RX14/crystal that referenced this pull request Sep 10, 2018
* Use blocking IO on a TTY if it can't be reopened

* Simplify tty fallback logic
ezrast pushed a commit to ezrast/crystal that referenced this pull request Oct 2, 2018
* Use blocking IO on a TTY if it can't be reopened

* Simplify tty fallback logic
@crysbot
Copy link

crysbot commented May 7, 2024

This pull request has been mentioned on Crystal Forum. There might be relevant details there:

https://forum.crystal-lang.org/t/unable-to-get-info-bad-file-descriptor-io-error/6820/16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants