Skip to content

Commit

Permalink
Add OpenBSD workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
dajohi committed Jan 4, 2019
1 parent 60ab7e3 commit 0938b51
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,21 @@ import "time"
func Init() error {
var err error

out, err = os.OpenFile("/dev/tty", syscall.O_WRONLY, 0)
if err != nil {
return err
}
in, err = syscall.Open("/dev/tty", syscall.O_RDONLY, 0)
if err != nil {
return err
if runtime.GOOS == "openbsd" {
out, err = os.OpenFile("/dev/tty", os.O_RDWR, 0)
if err != nil {
return err
}
in = int(out.Fd())
} else {
out, err = os.OpenFile("/dev/tty", os.O_WRONLY, 0)
if err != nil {
return err
}
in, err = syscall.Open("/dev/tty", syscall.O_RDONLY, 0)
if err != nil {
return err
}
}

err = setup_term()
Expand Down

0 comments on commit 0938b51

Please sign in to comment.