fd: Improve error handling of write_nonblock().