The officer in charge of a prison shall receive and detain all persons duly committed to his custody, under this Act or other wise, by any court, according to the exigency of any writ, warrant such person is discharged or removed in due course of law. ...