drain stdin before handling EPOLLHUP