The input isn't verified before using epoll on it
cardil opened this issue · 3 comments
Describe the bug
Bubbletea doesn't validate given input
, before trying to use epoll on it:
Line 55 in 7199a7f
When running processes, Golang (maybe other langs as well?) gives by default the /dev/null
as the stdin.
This in turn causes a cryptic epoll error, as the /dev/null
doesn't support epoll:
error creating cancelreader: add reader to epoll interest list
You could use muesli/cancelreader#13 to see the underlying syscall.Errno: EPERM
. Looking at epoll_ctl(2), the EPERM
is returned if:
The target file fd does not support epoll. This error can occur if fd refers to, for example, a regular file or a directory.
Setup
Please complete the following information along with version numbers, if applicable.
- OS: Linux
- Shell: zsh
- Terminal Emulator: Tilix
- Terminal Multiplexer: none
To Reproduce
Steps to reproduce the behavior:
- Checkout the repro: https://github.com/cardil/bubbletea-964
- Run test:
go test -count=1 ./spin2sec_test.go
- You should see
TestSpin2SecFailing
test failing, with error:error creating cancelreader: add reader with descriptor 0 to epoll interest list: operation not permitted
Expected behavior
Bubbletea should address a common case of having /dev/null
as input, and not feed it to epoll-based reader.
Walk around
To walk away of this problem, one might consider giving an empty buffer as process stdin. See, an example: wavesoftware/go-magetasks@7496084.
FYI: In Knative we walk around this issue with this function: https://github.com/knative/client-pkg/blob/ca64d2dc74eb7189060b3e39399d317ea402e35c/pkg/output/tui/bubbletea964.go#L30-L49