interface: close the fd before call CHECK_ERROR if it need to close fd