As one example when there is not sufficient means of dietary sustenance without eating meat.
If there is lack of sufficient vegetarian food necessary to sustain the body, then it is not immoral to eat nonvegetarian food for sustenance.
However there is no need for subjecting the animal or bird to unnecessary cruelty before death at least. That will be like killing it many times over. And definitely emotionally fragile and vulnerable infant animals and nursing mothers can be exempt from slaughter.
Compassion and mercy to animals have been emphasized in all religions as a meritorious act.
I remember reading an article about Prophet Muhammad admonishing a camel owner who was about to brand his camel on the face with a heated iron, and requesting him to brand it on the camel's rump instead. His argument was that the face is a sensitive part while the rump was not, and branding the camel on its rump would be less painful for the camel.
On an another occasion, Muhammad was about to commence his prayers when he saw a cat sleeping on his prayer mat. Muhammad silently and gingerly cut the free part of the mat without disturbing the sleeping cat, and then used it for his prayers. It's obvious from these examples that he was sensitive to the welfare of the animals around him.
Nonvegetarian Sikhs similarly kill the animal in a swift stroke so as to ensure a quick and painless death to the animal. This is known as
Jhatka and is obligatory for Sikhs. Animals killed painfully and slowly are forbidden for Sikhs.
Buddha's efforts similarly led to the substantial reduction of animal sacrifices in India, which was widespread in those times.
Emperor Ashoka, after his remorse following the carnage of the Kalinga war, adopted Buddhism as his faith, and became a vegetarian and stopped his daily diet of meat. Ashoka's rock edicts declare that injuring living things is not good, and no animal should be slaughtered for sacrifice though he did not prohibit common cattle slaughter or beef eating.
He imposed a ban on killing of "all four-footed creatures that are neither useful nor edible", and of specific animal species including several birds, certain types of fish and bulls among others. He also banned killing of female goats, sheep and pigs that were nursing their young; as well as their young up to the age of six months. He also banned killing of all fish and castration of animals during certain periods considered to be holy and auspicious.
Because he banned hunting, created many veterinary clinics and eliminated meat eating on many holidays, the Mauryan Empire under
Ashoka has been described as "one of the very few instances in world history of a government treating its animals as citizens who are as deserving of its protection as the human residents".
If Ashoka (c. 268 – c. 232 BCE ), more than 2300 years back could adopt measures reducing cruelty towards animals and ensuring their welfare, I am sure we can do the same in the twenty-first century A.D with much superior appliances, science and technology.