return -EAGAIN instead of 0 if failed to write.