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

update: fix bug on sleeping reader #214

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

coanor
Copy link

@coanor coanor commented Dec 13, 2020

[*] fix bug on sleeping read: during the sleeping 10ms, some
ctrl+x input will chaos the input line. Bug: #213 

	[*] fix bug on sleeping read: during the sleeping 10ms, some
	ctrl+x input will chaos the input line.
@c-bata
Copy link
Owner

c-bata commented Dec 14, 2020

Thank you for your pull request. But seemingly this PR makes the CPU usage 100% due to busy loop.

To fix the problem, we need to use solution like the following snippet. I'm sorry for your inconvenience. I have no enough time to fix this bug.
https://gist.github.com/c-bata/61c3e435c21f42a508a0f6bde139a954

@c-bata c-bata closed this Dec 14, 2020
@coanor
Copy link
Author

coanor commented Dec 15, 2020

Maybe you have not review all the code(no enought time ;)

I have removed syscall.SetNonblock() on /dev/tty, and set the bufCh blocking. No cpu 100%, I have tested it on linux/mac and windows.

The only defect is, the reading /dev/tty goroutine is leaked until os.Exit(), but this is not a serious problem(always only one reading groutine running). And I think we can merge the two groutine into 1, then no conmmunication need between them.

@c-bata c-bata reopened this Dec 15, 2020
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.

None yet

2 participants