Our decisions bold tbat except in cases concerning tbe care and custody of children no appeal lies from a judgment in habeas corpus proceedings, but tbe action of the judge must be reviewed, if at all, by writ of certiorari, which rests in tbe sound discretion of tbe appellate court. In re McCade, ante, 242, citing, among other authorities, In re Lee Croom, 175 N. C., 455; In re Holley, 154 N. C., 163.
Under these, and other decisions to like effect, this appeal, therefore, should be dismissed, but for the fact that the Attorney-General, waiving notice, has consented that the cause be heard and determined as on writ of certiorari, if such course meets the approval of the Court. The "Court having so determined and considered the cause in that aspect, it appears that the defendant has been found guilty of direct contempt of the mayor’s court of the city of Greenville, in violent abuse, and direct assault on the mayor while engaged in the administration of public justice and in the exercise of jurisdiction with which he is clothed. For such conduct he is held in custody under a sentence by the mayor, imposing imprisonment for thirty days and a fine of $200, and sues out this writ of habeas corpus to inquire and determine as to the legality of his detention.
It is held with us that the writ of habeas corpus cannot be made to serve the purpose of an appeal or writ of error. And our statute on the subject provides that on a hearing of this character the prisoner shall be remanded when it appears that he is held in custody:
1. By virtue of a process issued by a court or judge of the United States, in a case where such judge or court has exclusive jurisdiction.
2. By virtue of a final judgment or decree of any competent court of civil or criminal jurisdiction, or of any execution issued upon such judgment or decree.
3. For any contempt, specially and plainly charged in the commitment by some court, officer, or body having authority to commit for the contempt charged.
4. That the time during which such party may be legally detained has not expired.
*767And in tbe application and eonstrnction of these principles and tbe statutory provisions cited, it is tbe accepted position that where one is held under a final sentence of a court, a commitment of contempt or other, the only questions open to inquiry are whether on the record the court had jurisdiction of the matter, and whether on the facts disclosed in the record and under the law applicable to the case in hand, the court has exceeded its powers in imposing the sentence complained of. In re Lee Groom, 175 N. C., 455; In re Holley, supra.
Speaking to the question in Holley’s case, supra, the Court said: “And in determining this question of power the court is confined, as heretofore stated, to the record proper and the judgment itself. It is not permitted that the testimony or the rulings therein should be examined, into, nor that matters fairly in the discretion of the presiding judge should be reviewed, or that judgments erroneous in the ordinary acceptation of the term should be questioned. The hearing is nmrfi-np.fl to the record and judgment, and relief may be afforded only when on the record itself the judgment is one clearly and manifestly beyond the power of the court, a statement of the doctrine supported in numerous and authoritative decisions here and elsewhere,” citing Ex parte McCown, 139 N. C., 95; In re Schenck, 74 N. C., 607; In re Swan, 150 U. S., 637; In re Coy, 127 U. S., 731.
This being the recognized principle that prevails in a hearing and case of this kind, our statute on contempts being C. S., ch. 17, sec. 978 et seep, constitutes the acts and conduct of defendant, as established in this case, a direct contempt, authorizes punishment by imprisonment not to exceed thirty days or fine not to exceed $250, or both, in the discretion of the court, C. S., 981, and in express terms confers power to impose it on “every justice of the peace, referee, commissioner, clerk of the Superior, inferior, or criminal court, on the judges of Superior and Supreme Court, board of commissioners of Corporation Commission, when sitting on the trial of causes or engaged in official duties.” C. S., 983.
Defendant having been convicted and sentenced under the provisions of the statute, this is a final sentence, from which no appeal lies in the ordinary acceptation of the term, and where under the authorities cited, and others of like kind, can only be reversed or modified for a lack of power or jurisdiction of the court imposing the sentence. In re Groom, supra; S. v. Little, 175 N. C., 743; In re Brown, 168 N. C., 417; Ex parte McCown, 139 N. C., 95.
It is urged for petitioner that this sentence is beyond the power of the mayor’s court, which is only vested with the jurisdiction of a justice of the peace, and whose powers, therefore, under Article IY, section 27, of the Constitution, are restricted to a fine of $50 or imprisonment for 30 *768days, but the Court is of opinion that the limitations of this article and section apply, and were designed to apply, to the ordinary administration of the law in the trial of criminal causes, and were not intended to affect the inherent or statutory powers possessed by these courts and conferred upon them as necessary to enable them to transact business and maintain a proper “respect for their authority.” This is undoubtedly the Legislature’s construction of the section of the Constitution referred to, for, as we have said, the statute, in express terms, confers the power to punish and fine to the amount stated on the justices of the peace as well as on courts of record, and there are decisions here and elsewhere which strongly favor this view. In re Griffin, 98 N. C., 225; S. v. Lyon, 93 N. C., 575; People v. Toole, 35 Col., 225; 6 R. C. L., title Contempt, sec. 43.
In Griffin’s case, supra, speaking to the distinction and some of the differences that exist between proceedings for contempt and the ordinary administration of the criminal law, Smith, C. J., said: “The one belongs to the general administration of the criminal law, the other is the exercise of judicial authority inherent in the court, and indispensable in the exercise of its functions. If the act which shows the contempt constitutes a criminal offense, it may be prosecuted and punished as such notwithstanding the contempt may also be punished.”
And in S. v. Lyon, supra, in which it was held that a justice of the peace, in proper cases, had the power to require an adequate bond to keep the peace, and no appeal would lie, though the result might, in its practical operation, work an imprisonment far beyond the thirty days limitation on a justice’s jurisdiction, Merrimon, J., said: “This view is not in conflict with the provisions of the Constitution, Art. IV, sec. 27, and the statute on the subject. These provisions have reference to criminal cases wherein the magistrate gives judgment against a party charged with a criminal offense and imposes on him a punishment therefor.”
And in no event would the petitioner be entitled to his discharge on the facts of the present record. Even if the statute authorizing justices to both fine and imprison for direct contempt of court were invalid as violating the constitutional restrictions on their criminal jurisdiction, these courts have, with us, and without any statute, the inherent power to punish for direct contempt, when engaged in the administration of the State’s justice, and in the exercise of the jurisdiction and powers conferred upon them by the law. In re Deaton, 105 N. C., 59; Scott v. Fishblate, 117 N. C., 265; S. v. Aiken, 113 N. C., 651.
And this being true, even if the fine of $200 were invalid, the portion of the judgment inflicting an imprisonment for thirty days would be well within the constitutional provisions, and must be enforced according to its terms.
*769It is tbe established principle in cases of this character that when a prisoner is detained by virtue of a sentence in part valid, and part otherwise, he may not be liberated on habeas corpus till he shall have served the valid portion of his sentence. In re Holley, supra, citing U. S. v. Pridgen, 153 U. S., 48; Ex parte Erdman, 88 California, 578. A position directly recognized and approved in subsection four of our statute on habeas corpus as above quoted, “that the prisoner shall be remanded when it appears that the time during which he may be legally detained has not-expired.”
This will be certified that the judgment of the mayor’s court be enforced as entered.
Modified and affirmed.
Clark, O. J., did not sit.