Homicide is justifiable when committed by public officers and
those acting by their command in their aid and assistance, either–
1. In obedience to any judgment of a competent Court; or,
2. When necessarily committed in overcoming actual resistance to
the execution of some legal process, or in the discharge of any other
legal duty; or,
3. When necessarily committed in retaking felons who have been
rescued or have escaped, or when necessarily committed in arresting
persons charged with felony, and who are fleeing from justice or
resisting such arrest.
So,according to section 2,”or in the discharge of any other legal duty”,homicide is justified for pretty much everything.