handle EINTR when writing to log. Closes #461