goterm icon indicating copy to clipboard operation
goterm copied to clipboard

GetWinsize: inappropriate ioctl for device

Open dncohen opened this issue 9 years ago • 7 comments

Any idea why I get errors like these?

dave@tripper:goterm $ go run examples/chart_example.go                                  
Error: GetWinsize: inappropriate ioctl for device
dave@tripper:goterm $ go run examples/table_example.go                                  
Error: GetWinsize: inappropriate ioctl for device
dave@tripper:goterm $ go run examples/time_example.go                                   
Error: GetWinsize: inappropriate ioctl for device
Error: GetWinsize: inappropriate ioctl for device
Error: GetWinsize: inappropriate ioctl for device
Error: GetWinsize: inappropriate ioctl for device

Running on openbsd, if it matters. I've tried xterm, urxvt, tmux session - same error in each.

Thanks for any help.

dncohen avatar Aug 13 '16 07:08 dncohen

Hello! Can you clarify if it is 32 or 64 bit os?

On Sat, Aug 13, 2016 at 10:35 AM, dncohen [email protected] wrote:

Any idea why I get errors like these?

dave@tripper:goterm $ go run examples/chart_example.go Error: GetWinsize: inappropriate ioctl for device dave@tripper:goterm $ go run examples/table_example.go Error: GetWinsize: inappropriate ioctl for device dave@tripper:goterm $ go run examples/time_example.go Error: GetWinsize: inappropriate ioctl for device Error: GetWinsize: inappropriate ioctl for device Error: GetWinsize: inappropriate ioctl for device Error: GetWinsize: inappropriate ioctl for device

Running on openbsd, if it matters. I've tried xterm, urxvt, tmux session - same error in each.

Thanks for any help.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/buger/goterm/issues/6, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA2uYjzQMqL9TmHSgCJCRbZH9T19O7Nks5qfXPbgaJpZM4JjoOC .


Sincerely yours Leonid Bugaev http://gortool.com - test your system with real data

buger avatar Aug 13 '16 08:08 buger

64-bit openbsd. Was running go 1.6.2.

Upgraded to go 1.7, same problems.

dave@tripper:goterm [master] $ go run examples/chart_example.go  
Error: GetWinsize: inappropriate ioctl for device
dave@tripper:goterm [master] $ go version
go version go1.7 openbsd/amd64

dncohen avatar Aug 19 '16 06:08 dncohen

64-bit Ubuntu 14.04 running into the same issue.

bunkat avatar Nov 12 '16 08:11 bunkat

I have the same issue with code in attachement. test.zip

Unzip the archive, go in created directory and run 'go run test.go'. The library should look if parent is running in a terminal.

c4s4 avatar Jun 28 '17 13:06 c4s4

I have the same issue, but only when running my program to the right of a Unix pipe.

augustawind avatar Jul 12 '17 08:07 augustawind

https://github.com/buger/goterm/blob/master/terminal_sysioctl.go#L26 uses os.Stdin as an argument to the ioctl system call. When the standard input is not a terminal then os.Stdin is useless to ioctl hence inappropriate ioctl for device error.

The fix is to check whether os.Stdin is a tty, and if not, try os.Stdout or os.Stderr (vim does something like this https://github.com/vim/vim/blob/master/src/os_unix.c#L3861).

It's not perfect though, as it can still fail if those three were not ttys.

holygeek avatar Jul 22 '17 03:07 holygeek

updating the module worked for me go get -u github.com/buger/goterm

mh-cbon avatar Mar 11 '19 18:03 mh-cbon