Fixed a bug with stale errno on dumping