Penal Code § 1493
CHAPTER 1. Of the Writ of Habeas Corpus
In cases where any party is held under illegal restraint or custody, or any other person is entitled to the restraint or custody of such party, the Judge or Court may order such party to be committed to the restraint or custody of such person as is by law entitled thereto.