fix Bad file descriptor