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
termbox.PollEvent wait forever after reading from Stdin from tmux command #88
Comments
Works on my machine. Also your program expects "Esc" key which is available only in
What's the shortest way to reproduce it with tmux? You're saying it hands with multiple tmux sessions, does it hang with just one session? Is there some connection to number of sessions in general? I've noticed that the program hangs if stdin is empty, i.e. if you run it without sending stdin. What |
Oh, sorry. InputEsc is the default one. No need to add that line. |
On my machine this is the output of
and it freeze. I tried with just one session and the same thing happened. |
What about random output? Like |
Also what
|
I'm on 1.9a. |
Could you try 2.0 then? Maybe it will just work, who knows. |
Nope. It works the first time I launch it, and from the second time, nothing. |
Can you tell me exactly how to reproduce it? This is what I do: tmux
ls ~ | ./simplebox
# all works fine here
<C-b> <d> # detaching from session
tmux attach
ls ~ | ./simplebox
# all still works just fine I've deleted my tmux config file just in case. I don't see any hangs. |
That is what I did:
|
I tried without my |
It's really weird. I tried to do the same what you suggested. Works fine. |
Well, I remember there were some issues with termbox closing stdin or something like that. Try |
If it is not much trouble could you try as before but:
Sometimes it works a first time and then hangs. |
Tried 10 times or so. Works. |
It sucks that I can't reproduce it. I guess the issue will keep hanging there. Oh and I haven't asked what's your OS? Because I'm running it on linux and if it's a MacOSX, it changes everything. :D |
yes, I'm on Mac |
I should've told you sooner, sorry. |
Yeah, could be the mac issue, because I don't have a mac and therefore it's the least tested OS when it comes to termbox-go. Yeah, it's mostly POSIX and the implementation is similar, but there could be slight differences in syscalls behaviour. Like when SIGIO is sent and what Read returns. Sadly I don't have a mac, so at this moment I can't help you. Maybe I'll eventually try to get hackintosh running in a virtualbox or something. |
If you need some testing I could do it, just tell me what to do :) Anyway thanks for your time 👍 |
There is a same issue(peco/peco#255). So I also think this is MacOSX kernel issue. |
Well, I'm sure any modern OS has some proper way of doing async I/O. That's what termbox requires. The reason for this is a need to be able to do graceful shutdown. We can't just block a goroutine waiting for input, because if library user decides to quit, you can't unblock a read syscall. That's how I do it on windows (btw, haven't tested enough, not sure if it even works correctly): https://github.com/nsf/termbox-go/blob/master/termbox_windows.go#L743-L813 Basically a similar solution to POSIX's I'm pretty sure it's all possible on all OSes. All OSes have some kind of a semaphore implementation (that is a waiting queue for threads and a way to wake them up) and some kind of a multi-object management system, be it |
I have no idea yet. |
And I have no time to figure that out. When I have, I will. |
I believe there is an excellent chance that my fix in PR #99 will solve this. After that change is pulled, termbox-go no longer depends on or uses either SIGIO or async/IO. Please give it a whirl. |
I don't know if this is a problem with termbox-go per se.
I have this simple program https://gist.github.com/vheon/74388c0dd68e21413eb8. If I ran this as
everything works fine, if I press
<C-n>
or<C-p>
the selected line change.if I have multiple sessions inside tmux and run
everything freeze and the only way to exit is to
killall "simplebox"
from another shell. I checked and the program is blocked on PollEvent.The text was updated successfully, but these errors were encountered: