meek-client doesn't exit on close of stdin if there are no active handlers running
If you give meek-client an EOF while it's not currently handling any connections, it says it is terminating but doesn't quite terminate.
$ TOR_PT_EXIT_ON_STDIN_CLOSE=1 TOR_PT_MANAGED_TRANSPORT_VER=1 TOR_PT_CLIENT_TRANSPORTS=meek ./meek-client < /dev/null
VERSION 1
CMETHOD meek socks5 127.0.0.1:35831
2018/01/11 22:03:23 listening on 127.0.0.1:35831
CMETHODS DONE
2018/01/11 22:03:23 synthesizing SIGTERM because of stdin close
2018/01/11 22:03:23 got signal terminated
2018/01/11 22:03:23 error in AcceptSocks: accept tcp 127.0.0.1:35831: use of closed network connection
It's stuck in this loop, because it only checks numHandlers == 0
inside the loop and not before entering.
for n := range handlerChan {
numHandlers += n
if numHandlers == 0 {
break
}
}