When doing safe writes, handle EAGAIN rather than raising an exception