BurntSushi / xgb

The X Go Binding is a low-level API to communicate with the X server. It is modeled on XCB and supports many X extensions.
Other
489 stars 75 forks source link

Unable to close a connection's eventChan #4

Closed tones111 closed 11 years ago

tones111 commented 11 years ago

I'm writing a wrapper around go.wde (which uses xgb as a backend) and can't seem to find a good way to close down the X connection. When attempting to close a window go.wde gets hung up in WaitForEvent() since no new events are coming down the channel.

The receive operation in WaitForEvent() could complete if eventChan were to be closed, which requires breaking out of the infinite loop in ReadResponses(). My first attempt was to call the connection's Close() method to prevent the io.ReadFull() call from blocking but that generates the following messy error: XGB: log.go:29: Read error: read unix /tmp/.X11-unix/X0: use of closed network connection.

So, what's the right way to shut down a connection and allow the xgb goroutines to close their channels and return gracefully?