Habeas corpus is a writ commanding a person who has another in his custody to produce him before the court and to state the authority for the custody.
Custody, as used in this Chapter, includes detention and confinement.
A petition for a writ of habeas corpus may be filed by the person in custody or by any other person in his behalf.