If the person in custody is being held by virtue of a court order, relief shall be granted only on the following grounds:
(1) The court has exceeded its jurisdiction;
(2) The original custody was lawful, but by some act, omission, or event which has since occurred, the custody has become unlawful;
(3) The order for the custody is deficient in some legal requisite;
(4) The order for the custody, although legal in form, imposes an illegal custody;
(5) The custodian is not the person allowed by law to detain the person in custody;
(6) He has been denied his right to a hearing in an extradition case, as provided in Article 267; or
(7) He is being held in custody prior to trial in violation of due process of law.
Amended by Acts 1980, No. 429, §2, eff. Jan. 1, 1981.