The general function and purpose of the writ is to determine whether the person in whose behalf the writ is granted is detained or held in custody lawfully or unlawfully. The cases where the writ is used may be broadly classified as those where the person is detained without any legal process, and where he is held under some form of legal proceedings, which may or may not be lawful. The first of these classes is ex .emplified where one parent seeks to obtain the custody of a child under the control and in the •custody of the other parent or some other per son, and for that purpose obtains a writ in be half of the child, setting up the illegal confine ment of the child. Here the merits of the whole case must be heard and determined in order to decide to whom the custody of the child lawfully belongs. So, in the case of a person confined as an insane person, without legal process, the mer its of the case must be heard and decided, both as to whether the person is insane, and if so whether the confinement is lawful. Where the confinement is under legal process, however, the purpose and function of the writ is to procure a hearing and determination as to the question whether the confining authority is lawfully exer cising its jurisdiction or not. Mere irregularity does not necessarily deprive the court of jurisdic tion; but when the irregularity is so material that no jurisdiction over the prisoner has been obtained for the purpose of confinement, then the prisoner will be discharged. In other words,
generally speaking, the writ cannot be used to do away with the regular trial of an action, or to inquire into the merits of proceedings any further than this is necessary to determine the legality of the confinement complained of.
The procedure by which the writ is obtained, both at common law and under the various stat utes regulating the subjects in some of the States, is by some form of a petition or motion signed by the party or some one in his behalf, setting up such facts as are necessary to make out a prima facie case. The person entitled to custody of one illegally detained by another, as a father deprived of his child, may himself apply for the writ. The courts of the Federal Govern ment in the United States have the discretionary right to withhold it; but in some of the States the writ must be granted, as in England, upon a proper petition or motion.
The question as to when the Federal and when the State courts have authority in cases where their authorities clash with each other is deter mined by the general principles governing the conflict of laws between the two. For a discus sion of that subject, and of the method of return of the writ, the general principles of jurisdiction.
•ete., see the titles CONFLICT OF LAWS; CONSTI TUTIONAL LAW ; WRIT; JUTISDICTIOZT, etc.