Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
(*Instance) Close function call blocks until line is received #52
Connection to one or more servers in their own go routines, with a sync.WaitGroup that will terminate the program if all servers are disconnected. Signal monitoring, which also monitors a boolean quit channel, so if a quit command is entered in the terminal window, the program will quit. Checks on the readline instance to determine if an interrupt of any kind is received, which will also quit the program. Entering the quot command in the terminal, or CTRL+C for interrupts shuts the program down cleanly, but trying to kill the program by sending it a signal will not terminate the program until enter is pressed, or likely, some other signal interrupt received.
Briefly, here is how I believe this could be reproduced.
My question is this. Is the Close() function call supposed to block like this? Or, could I read input in another way that would return an error immediately after the readline instance is closed, and not block on the readline instance Close() method? I could then completely end the program without the need for an extra step of entering a blank newline or otherwise.
pushed a commit
Aug 31, 2016
I believe I am experiencing the same issue with https://github.com/hashrocket/ws. That is a tool for connecting to a websocket server (similar to telnet). In one goroutine I read from readline and in another I read from the websocket. If/when the websocket is closed I want to also close readline and terminate the program. Unfortunately, Readline() blocks until a key is pressed. And Close() blocks until Readline is finished. I can simply os.Exit() the program, but then the terminal may be left in a bad state.
For what it's worth I hacked around the issue with this change: