When a person has once been discharged on habeas corpus, he cannot be again imprisoned, restrained or kept in custody for the same cause, unless he is indicted therefor or, after a discharge for defect of proof, is again arrested on sufficient proof and committed by legal process.