The writ of "habeas corpus ad subjiciendum" is a civil, not criminal, "ex parte" proceeding in which a court inquires as to the legitimacy of a prisoner's custody. Typically, "habeas corpus" proceedings are to determine whether the court that imposed sentence on the defendant had jurisdiction and authority to do so, or whether the defendant's sentence has expired. "Habeas corpus" is also used as a legal avenue to challenge other types of custody such as pretrial detention or detention by the United States Bureau of Immigration and Customs Enforcement pursuant to a deportation proceeding.