Avoid modifying global errno when raising event