deal properly with closed fds in keepalive