This is all according to Islamic law. Here is a salient passage on this issue from a Shafi’i manual of Islamic law:
When an adult male is taken captive, the caliph considers the interests … (of Islam and the Muslims) and decides between the prisoner’s death, slavery, release without paying anything, or ransoming himself in exchange for money or for a Muslim captive held by the enemy. (Reliance of the Traveller o9.14)
A revered Islamic jurist, Al-Mawardi, agrees with Reliance of the Traveller:
As for the captives, the amir has the choice of taking the most beneficial action of four possibilities: the first, to put them to death by cutting their necks; the second, to enslave them and apply the laws of slavery regarding their sale or manumission; the third, to ransom them in exchange for goods or prisoners; and fourth, to show favor to them and pardon them. (Al-Ahkam As-Sultaniyyah (The Laws of Islamic Governance), 4.5)
“Live: Barcelona terror attack: Multiple casualties as van ploughs into crowd at Las Ramblas,” by Nicky Harley, James Rothwell, and Victoria Ward, Telegraph, August 17, 2017:
At least two people have reportedly been killed and several others are injured after a suspected terrorist crashed into a crowd of people on a pavement in a popular tourist area of Barcelona.
There are also reports of a live hostage incident at a Turkish restaurant near the scene….