It is lawful for a person who is charged by law with the duty of executing the lawful process of a court, and who is required to arrest or detain another person under such process, and for every person lawfully assisting a person so charged, to arrest or detain that other person according to the terms of the process.