On FreeBSD and OpenBSD, the syscall.Read call in the anonymous goroutine in Init blocks. This causes problems during Close: the send to the quit channel blocks, because the anonymous goroutine is blocked on syscall.Read, and things remain blocked until syscall.Read returns.
Init sets the in file descriptor to nonblocking with fcntl, but—on FreeBSD and OpenBSD—the in fd and the out fd are the same, and every out.Fd call clears nonblocking flag. This problem can be fixed by saving the out.Fd in a variable prior to setting the in fd to nonblocking, and using that variable afterward instead of out.Fd.
This fixes a bug in godit on FreeBSD. Without this change, C-x C-c hangs, leaving the editor on the screen: to clear the hang, you have to type arbitrary characters so that the syscall.Read returns and then the anonymous goroutine picks up on the quit signal. With this change, C-x C-c works correctly on FreeBSD.
On FreeBSD and OpenBSD, the
syscall.Read
call in the anonymous goroutine inInit
blocks. This causes problems duringClose
: the send to thequit
channel blocks, because the anonymous goroutine is blocked onsyscall.Read
, and things remain blocked untilsyscall.Read
returns.Init
sets thein
file descriptor to nonblocking withfcntl
, but—on FreeBSD and OpenBSD—thein
fd and theout
fd are the same, and everyout.Fd
call clears nonblocking flag. This problem can be fixed by saving theout.Fd
in a variable prior to setting thein
fd to nonblocking, and using that variable afterward instead ofout.Fd
.https://github.com/nsf/termbox-go/issues/167 is related.
This fixes a bug in godit on FreeBSD. Without this change,
C-x C-c
hangs, leaving the editor on the screen: to clear the hang, you have to type arbitrary characters so that thesyscall.Read
returns and then the anonymous goroutine picks up on the quit signal. With this change,C-x C-c
works correctly on FreeBSD.