Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Did not work with Mac #2

Open
alexisvisco opened this issue Oct 26, 2018 · 6 comments
Open

Did not work with Mac #2

alexisvisco opened this issue Oct 26, 2018 · 6 comments

Comments

@alexisvisco
Copy link

Hello,

Your library don't work with max osx version High Sierra v10.13.6.

Problem

At this function:

func cTermios(goTerm *Termios) *C.struct_termios {
	var cTerm C.struct_termios

	cTerm.c_iflag = C.tcflag_t(goTerm.IFlag)
	cTerm.c_oflag = C.tcflag_t(goTerm.OFlag)
	cTerm.c_cflag = C.tcflag_t(goTerm.CFlag)
	cTerm.c_lflag = C.tcflag_t(goTerm.LFlag)
	for idx, ch := range goTerm.CC {
		cTerm.c_cc[idx] = C.cc_t(ch) // Here there is the error
	}
	cTerm.c_ispeed = C.speed_t(goTerm.ISpeed)
	cTerm.c_ospeed = C.speed_t(goTerm.OSpeed)

	return &cTerm
}

You got an out of range:

➜  taskmaster git:(line-edit) ✗ go run cmd/taskmaster/main.go
tsh> panic: runtime error: index out of range

goroutine 1 [running]:
github.com/k0kubun/go-termios.cTermios(0xc000042e08, 0xc000000000)
        /Users/alexis/go/src/github.com/k0kubun/go-termios/termios.go:261 +0xad
github.com/k0kubun/go-termios.(*Termios).SetAttr(0xc000042e08, 0x0, 0x2, 0x0, 0x40ad1c0)
        /Users/alexis/go/src/github.com/k0kubun/go-termios/termios.go:230 +0x2f
github.com/remicaumette/taskmaster/cli/in.Read(0x402a958, 0x40d0d92, 0x5, 0x5)
        /Users/alexis/go/src/github.com/remicaumette/taskmaster/cli/in/reader.go:44 +0xfe
github.com/remicaumette/taskmaster/cli/readline.(*Readline).readProcess(0xc0000a4000)
        /Users/alexis/go/src/github.com/remicaumette/taskmaster/cli/readline/readline.go:113 +0x26
github.com/remicaumette/taskmaster/cli/readline.Read(0x40d0d92, 0x5, 0x0, 0x0, 0xc000042f88, 0xc00007c058)
        /Users/alexis/go/src/github.com/remicaumette/taskmaster/cli/readline/readline.go:48 +0x19b
main.main()
        /Users/alexis/go/src/github.com/remicaumette/taskmaster/cmd/taskmaster/main.go:7 +0x36
exit status 2

I've tryed to protect cTerm.c_cc to not get an out of range for idx. But the behaviour is not like ubuntu, there is no keys that it read. (Because it work as expected on ubuntu).

Thanks you !

@k0kubun
Copy link
Owner

k0kubun commented Oct 26, 2018

Thanks to report. TBH I have no memory about this library since my own last commit was 4 years ago. Do you have any idea to fix this?

@alexisvisco
Copy link
Author

I think i will investigate after work, maybe you will see a pull request in the week end !

But if you can investigate too i will be happy too because i am not really sure about the cause ;)

@alexisvisco
Copy link
Author

maybe this issue from another library can help you:
creack/termios#2

@alexisvisco
Copy link
Author

Okay seems that your struct field CC (of go) has a len of 32, (for an unknown reason) and i think you should set the const:

NCCS = 32 // size of c_cc[] to 20.

Maybe test your code on a real linux system and not a mac.

For my part, this is fixed.

@alexisvisco
Copy link
Author

back to linux, okay this solution not work, NCCS vary in function of which system you are using !

@k0kubun
Copy link
Owner

k0kubun commented Oct 27, 2018

I have no spare time to deal with this immediately. If you want, could you send a pull request to this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants