handle select() error condition; more commented cleanup code