
4 Cal.2d 136 (1935)
THE PEOPLE, Petitioner,
v.
SUPERIOR COURT OF CONTRA COSTA COUNTY et al., Respondents.
S. F. No. 15311. 
Supreme Court of California. In Bank.  
July 30, 1935.
 U.S. Webb, Attorney-General, Lionel Browne, Deputy Attorney-General, James F. Hoey and Francis F. Healey, District Attorneys, and Warren Cunningham, Deputy District Attorney, for Petitioner.
 George C. Carmody and W. L. Wollitz for Respondents.
 SEAWELL, J.
 On September 8, 1909, an information was filed in the Superior Court of the County of Contra Costa *139 by the district attorney, charging the defendant with the crime of murder. On September 10, 1909, defendant, with his consent, was arraigned. On September 20, 1909, defendant entered his plea of "not guilty" to the crime charged in the information and the cause was set for trial to begin on September 23, 1909. Several postponements followed. On December 13, 1909, two physicians, appointed by the court upon suggestion that the defendant was then insane, certified to the court that in their opinion he was then insane. On December 21, 1909, defendant, accompanied by his counsel, was brought into court for trial, and the court having entertained a doubt as to his sanity ordered that that question be submitted to a jury, and that his trial be suspended until the issue of his sanity should be determined by jury trial. A jury trial was had forthwith. The only witnesses called in the matter were three physicians. The case was submitted to the jury upon the court's instructions and without argument by counsel. The jury on the same day returned a verdict finding the defendant to be then insane. The court thereupon ordered that the defendant be committed by the sheriff of Contra Costa County to the Stockton state hospital. The court further ordered that the trial of the defendant be suspended and upon his becoming sane that "he shall be delivered to the sheriff of the County of Contra Costa ... to be placed and held by him in proper custody until he is brought to trial or is legally discharged". On May 2, 1910, accompanied by his attorneys, the defendant was returned into court by the sheriff and the court ordered the cause set for May 4, 1910, for trial, and remanded the defendant into the custody of the sheriff. On said trial day the defendant was brought into court and A. B. McKenzie, Esq., was by formal order associated with C. C. Brown, Esq., in his defense. The defendant consented that the cause be set for trial beginning May 17, 1910. Before said trial day, to wit, May 9, 1910, the defendant in open court asked permission to withdraw his plea of not guilty, which had been entered prior to the institution of the insanity proceeding.
 The district attorney gave his consent to the withdrawal of said plea of not guilty to the information, which charged murder in the first degree. Thereupon the defendant, by permission of the court, withdrew said plea and entered a plea of guilty of murder in the second degree. This plea *140 removed from the case the possibility of imposing upon the defendant the death penalty. He was asked if he had any legal cause to show why judgment should not be pronounced against him, and replied in person that he had not. The court thereupon fixed his punishment at fifty years' imprisonment in the state prison at San Quentin. All of the proceedings thus far taken were held approximately twenty-five years prior to the proceedings herein instituted, before the Honorable R. H. Latimer, long since deceased, who at all of said times mentioned was the only judge of the Superior Court of Contra Costa County.
 [1] No attack of any kind whatever was made upon the judgment entered on said plea of guilty during the quarter of a century that had passed since its pronouncement until the defendant filed on April 13, 1934, with the county clerk of the county of Contra Costa, this belated application for the issuance of the ancient writ of error coram nobis, which is seldom invoked or granted as the remedial provisions of modern statutes and procedure provide every relief that could be granted under the ancient writ. The defendant based his right to the writ on the ground that when he entered his plea of guilty to murder in the second degree he was under commitment of a judgment pronouncing him insane and no order of restoration to sanity had been made as provided by law, and therefore his plea was taken while he was under adjudication of insanity and the judgment pronounced on it was null and void. It is not contended, and such contention could not be sustained, that he was in fact insane when he entered said plea of guilty. Defendant does not ask for an outright discharge from custody but makes the more modest requests that the judgment be set aside and that "he be brought before this Honorable Court (Superior Court) and allowed to withdraw his former plea of guilty and enter a plea of not guilty and be given a trial on the merits of his case". It is probable that after the flight of approximately twenty-five years the defendant is the only person alive who has intimate knowledge of the facts bearing on the homicide. There can be no doubt that death, and memories dimmed by the flight of years and the dispersing of witnesses, if any remain alive, would make it altogether unlikely that the case could be heard and determined at this late day "on its merits". Such a request, if made years ago, could have been complied with *141 at a time when conditions were much more favorable to a full and fair disclosure of the facts of the homicide. We may take judicial notice that the judge who tried the case and who had to do with the insanity proceedings, and the district attorney, H. V. Alvarado, afterwards judge of the Superior Court, and the clerk of the court, custodian of the court records and who, as well as the other officials named, might have been a witness as to the existence and contents of certain papers and documents touching the insanity proceedings which were not required by law to be filed but which might have thrown some light on controverted matters, are all dead. There is also a strong probability as to the demise of others whose testimony cannot now be obtained. That the adjudication of the defendant's insanity, which was invoked in the first instance to the advantage of the defendant, and which is now attempted to be turned to his further advantage as a means of annulling a judgment of imprisonment imposed with the personal connivance of the defendant, was obtained by the practice of fraud and imposition upon the court will clearly appear from a statement of the proceedings and the facts, both current and subsequent to the order made postponing the trial on the ground that the defendant was presently insane. It was not claimed that the defendant was insane at the time he committed the murder, but that he became insane after he entered his plea of not guilty and after an order had been made setting the case for trial. Within less than five months later the defendant was delivered by the superintendent of the state hospital as a person not insane to the sheriff of the county of Contra Costa and by him returned to the same court which had made the order of commitment. Being present with his counsel, the defendant personally requested that he be permitted to withdraw his former plea of not guilty, which was entered at a time when no question was raised, nor has since been raised, as to his sanity at the time he plead not guilty of the crime charged. Counsel made no suggestion that the defendant was still insane at the time he was brought into court and requested, and was permitted, to change his plea of not guilty to guilty of a lesser degree of murder included within the charge. In fact to have done so would have endangered his chances of eliminating the death penalty as a possibility from the case. The district attorney, on the other hand, had a commitment of *142 insanity of the defendant to combat. While it did not go to his sanity at the time the murder was committed, it would have been admissible should the defendant have elected to plead insanity as a defense to the homicide. (People v. Farrell, 31 Cal. 576.) Doubtless it was because of the record which he would have been compelled to combat that the district attorney consented to a plea of guilty of murder in the second degree. The court must have been impressed with the atrocity of the crime and the entire responsibility of the defendant, as it imposed a penalty of fifty years' imprisonment upon him. No objection was made to the proceedings which were in fact joined in, if not set in motion by the defendant, and no appeal was noticed or taken by the defendant until some twenty-five years thereafter. It was not claimed or suggested that he was laboring under any form of insanity. His position is that he was sane at a specific date for the purpose of gaining an immediate advantage, but insane at said time for the purpose of invalidating the proceedings which he invoked to reduce the penalty of his crime and in which he personally participated as a sane person. The law is not so impotent as to give its sanction to this sort of duplicity and double dealing when it becomes so clearly developed as it is in the instant case.
 The proceeding by which the judgment of the superior court was annulled upon the issuance of the writ of error coram nobis was presented to the court by the defendant in propria persona. His attorneys thereafter appeared of record.
 [2] The defendant's objections to the proceedings had on the issue of insanity are based upon noncompliance with the general provisions of the Political Code, which are entirely distinct from the proceedings authorized by the Penal Code providing for inquiry to be made of the defendant's sanity before trial or after conviction, as provided by part 2, title 10, chapter 6, of the Penal Code. [3] Sections 1368, 1369 and 1370 provide the procedure in case a doubt arises as to the sanity of a defendant during the pendency of a criminal action against him, and for the suspension of trial or judgment until his sanity be determined. If the jury trying the issue find him insane the trial is suspended until he becomes sane and the court must order "that he be in the meantime committed by the sheriff to a state hospital for the care and *143 treatment of the insane, and that upon his becoming sane he be redelivered to the sheriff". (Sec. 1370, Pen. Code.) Section 1372 of said chapter provides: "... when he becomes sane, the superintendent must certify that fact to the sheriff and district attorney of the county. The sheriff must thereupon, without delay, bring the defendant from the state hospital, and place him in proper custody until he is brought to trial or judgment as the case may be, or is legally discharged." The procedure regulating the determination of the sanity of persons placed on trial for the commission of crime is substantially as it was when enacted in 1851. It is fully set forth under the identical heading it bears in our present Penal Code, under chapter III, pages 277, 278, Statutes, Second Session, 1851. At that time the defendant was committed to the custody of the sheriff, who in turn was authorized to commit him to the custody of some proper person to be redelivered to the sheriff upon his becoming sane. Upon his becoming sane the person having his custody was required to give notice to the sheriff and district attorney of the county in which the trial was pending. The sheriff thereupon placed him in proper custody until he was brought to trial or judgment or was otherwise legally discharged. The custody of the defendant, if found by the jury to be insane, is, under our present law, given to the state hospital, an institution which had no existence in our more primitive statehood, in place of a person delegated by the sheriff. The procedure as defined by our Penal Code in determining the defendant's insanity has remained unchanged, with the one exception noted in part 3, title V, chapter 1, "State Commission in Lunacy", etc., section 2189, subdivision 5 of the Political Code, which is expressly applicable to the criminal procedure in words as follows: "Patients charged with crime. [4] A patient committed to a hospital under the provisions of chapter 6, title 10, part 2, of the Penal Code, must, upon the certificate of the superintendent that such person has recovered, approved by the superior judge of the county from which the patient was committed, be redelivered to the sheriff of such county, and dealt with as provided for by said chapter 6 of the Penal Code." This is the only section of the general law governing the conduct and management of public institutions which purports to add to or change any rule of procedure providing for the trial of persons whose sanity is *144 questioned. That section in no way affects the validity of the proceedings of the instant case. It merely is a command to all who have any part in the prosecution of such cases to proceed to do their duty as defined by the penal statutes referred to. It makes the redelivery of such persons to the sheriff and placing them on trial mandatory. The word must relates to the redelivery of such persons to the sheriff for the purpose of proceeding against them as by the Penal Code provided. The provisions of the act were substantially complied with, however, in the instant case, as will be shown from the records of the state hospital, so far as the superintendent of the state hospital was involved. The judge who signed the order was the same judge who pronounced judgment on defendant's plea. The sole object of the act is to give notice to those charged with the duty of bringing the defendant to trial that he has recovered, or that in fact he was not insane, notwithstanding the verdict of the jury. The superintendent of the state hospital did not believe the defendant was insane at any time, as shown by his correspondence with the sheriff. Therefore he could not make a certificate that he had "recovered". He did make a record and reported to the sheriff, and doubtless to the court, that the defendant was "not insane". He repeatedly informed the sheriff that he was malingering and was not insane when committed. It was not important whether he had recovered his sanity or whether his mental condition had never been impaired. In either case he was in a proper mental condition to be returned by the sheriff to court for trial.
 [5] Before reviewing the proceedings as presented by a scant record purporting to record events which transpired many years ago, it is important to keep in mind the fact that the procedure prescribed by the Penal Code is entirely distinct from that prescribed by the Code of Civil Procedure and the general and more comprehensive law relating to insane and incompetent persons and their commitment to, confinement in and discharge from state hospitals. A clear distinction is made with respect to proceedings authorized by the Code of Civil Procedure and those had under the provisions of the Political Code in Kellogg v. Cochran, 87 Cal. 192 [25 P. 677, 12 L.R.A. 104]. It is there said: "... it seems clear that the proceeding against insane and other mentally incompetent persons, authorized by the Code of *145 Civil Procedure, is entirely distinct from the proceedings authorized by the Political Code for the commitment of insane persons to the state insane asylum."
 "The provision in section 1766 of the Code of Civil Procedure authorizing the court to restore the person adjudged insane or incompetent to capacity is only applicable to persons adjudged insane or incompetent, and for whom guardians have been appointed under section 1764 of the same code. The application of it to persons committed to the asylums would be utterly inconsistent with the government of those institutions according to the requirements and regulations of the Political Code. After a person has been committed to either of the insane asylums on a charge of insanity, and received into the asylum, no court in this state is authorized to discharge him therefrom, or to restore him to the capacity of a sane person, under any circumstances, except upon writ of habeas corpus. The power to discharge him otherwise than upon habeas corpus is vested exclusively in the officers of the asylum." The subject is more nearly related in said two codes than it is to the exclusive Penal Code procedure. In the former, restoration to capacity is considered with respect to competency to contract, affecting guardianships, custody of minor children, protection of the estates of incompetents, capacity to sue and the enjoyment of civil rights generally. The Penal Code does not undertake to deal with such subjects. It prescribes a summary procedure for the determination of the question as to whether the defendant is so far mentally affected as to prevent him from defending himself against the crime with which he is charged. The procedure merely defines the duty of the judge, district attorney, and the sheriff and superintendent of the state hospital, all of whom are officers who either have the custody of the defendant or who are charged with the performance of judicial or executive duties in the prosecution of persons charged with the commission of crime. [6] The Penal Code undoubtedly prescribes the exclusive manner by which the proceedings shall be set in motion when the defendant is restored to sanity or is not insane.
 [7] Any person held in custody as an insane or incompetent person, under the laws of this state, has always been entitled to the writ of habeas corpus. (Kellogg v. Cochran, supra; sec. 2188, Pol. Code.) The order of commitment "is *146 not final or conclusive as to the resident physician of the asylum, whose duty it is to disregard it if in his opinion it was not properly made. Indeed, the final determination as to whether the person committed is insane or not is to be made and announced by the resident physician of the asylum. The proceeding before the judge is only preliminary, and is analogous to the preliminary examination of a criminal charged by a magistrate". (Kellogg v. Cochran, supra.) The medical superintendent of the Stockton state hospital at the time defendant was ordered placed and detained in said institution until his discharge was Dr. Fred P. Clark, a psychiatrist of high repute in this state, long since deceased, and that he believed from the first that the defendant was simulating insanity is shown by the following communications with Sheriff R. R. Veale of Contra Costa County, the first of which he addressed but two weeks after the defendant was delivered to said institution:
 "January 5, 1910:"
 "Your letter received. I am much obliged for the information contained in it."
 "I do not think your man McFarland is insane but would prefer to have him with us for a while longer in order that I may be positive of that fact. He eats as heartily as any of the patients, talks very well, and I think his mental condition is a mere sham."
 "Yours truly,"
 "Medical Superintendent."
 On January 21, 1910, he wrote as follows:
 "Your friend McFarland is doing very well. As I wrote you before, I do not think he is insane. I expect to have a clinic on him next week, and will then decide whether to return him to you or not."
 On April 6, 1910, he wrote his final conclusion as to the insanity of the defendant, requesting the sheriff to take him into custody for the purposes of trial:
 "Enclosed you will find a copy of letter received from the Chief of Police of Morristown, Pa., which shows that our man McFarland has been trying to impose upon us in regard to his sanity. I think he has been feigning insanity all along so I wish you would send some one after him in order that he may be returned for trial as I do not think he is insane." *147
 At the hearing of the petition herein George A. Brown, Jr., secretary of the Stockton state hospital since June 1, 1913, produced the "Register of Discharges, Insane Asylum Office", a book officially kept in which entries were duly made by the secretary in the performance of official duty, giving names of the inmates, where sent, date of discharge, reasons therefor and the names of the persons, if any, to whom the custody of said discharged persons was awarded. In said record in separate columns there appears the following under date of April 26, 1910: "Name. James McFarland. Where sent: With the Sheriff to Contra Costa County. Not insane."
 Here we have absolute proof that the medical superintendent, both by his several letters to the sheriff, which constitute notice as fully as if he had used the word "certify", and by the entry upon the official records of the state hospital that the defendant was not insane and was accordingly discharged therefrom. The medical superintendent, whose qualifications to occupy this position are prescribed by the code, is the final arbiter of that question. [8] The statute does not require the certification to be in any particular form. It is, at most, merely a formal statement made to the sheriff and district attorney that the defendant is not insane, and there is in fact no specific requirement that it be filed, nor does there appear to be great reason why it should be.
 [9] It appears by affirmative proof that the superintendent of hospitals not only caused official record to be made as to defendant's sanity, but made written report to that effect to the sheriff and requested him to take the defendant into his custody. The district attorney who participated in the proceeding, now deceased, is presumed to have had knowledge of the law and to have acted in compliance with its requirements. It is a satisfactory presumption "That official duty has been regularly performed." (Sec. 1963, subd. 15, Code Civ. Proc.) Similarly a presumption will be indulged with respect to the judge, since deceased, who presided at the insanity proceeding and who afterwards granted defendant's motion to withdraw his former plea of not guilty and enter a plea of guilty to murder in the second degree. The same judge pronounced final judgment. There is also the further presumption "That a Court or judge acting as such was acting in the lawful exercise of his jurisdiction." (Sec. 1963, Code Civ. Proc., subd. 16.) It will be presumed *148 that the report or certification of the superintendent of state hospitals as to the sanity of the defendant met with the approval of the court. Especially is this true when the same judge presided at all of said proceedings. [10] The sole object and purpose of the procedure as set forth in chapter 6, part 2, title 10, of the Penal Code is to bring to trial a person whose trial has been suspended by reason of a verdict of insanity and an order of commitment to the state hospital, upon a finding being made by the superintendent of the state hospital to which he has been committed, together with the approval of the court in which the matter is pending, to the effect that the defendant has become sane, or that he is sane. A certification to the sheriff and district attorney is but a direction, ministerial in character, to said officers to take notice of the finding of sanity and act accordingly. When they have as a matter of fact acted the mandate of the statute has been complied with.
 The judgment pronounced on the plea of guilty was clearly valid.
 The attack made on the judgment approximately a quarter of a century after it was procured to be entered through the active participation of the defendant himself and in the circumstances herein related was presented in propria persona to the Superior Court of the County of Contra Costa on April 13, 1934, and is denominated a writ of error coram nobis. It is in effect an attack upon the judgment, asking that it be set aside as void on the grounds and for the reasons already noticed, and that the defendant be allowed to enter a plea of not guilty. The petition for the writ sets out eleven instances or situations in which the issuance of the writ was held proper in certain foreign jurisdictions. Of the eleven, none are germane to the situation before us. The first one makes the nearest approach to the issue. It is: "1. Where the defendant was insane at the time of the trial and this fact was unknown to the Court. (Hydrick v. State, 104 Ark. 43 [148 S.W. 541].)" This ground for granting the ancient and somewhat obsolete writ is disposed of by the fact that the defendant was neither in fact nor in law insane at the time of trial and his mental status could not have been unknown to the court who presided at the proceedings and had to determine the question of sanity and who afterward, upon defendant's return to court, permitted him upon his *149 personal request to withdraw his former plea. If the court had entertained a doubt as to his sanity when he appeared even after his discharge from the state hospital, it could and would have again ordered the question submitted to a jury as provided by section 1368, Penal Code. The court must order this question submitted to a jury whenever he entertains a doubt as to the defendant's insanity at any stage of the proceedings.
 No claim is made that the plea was procured by extrinsic fraud, or was extorted through fear of mob violence or was induced by any of the methods which afforded grounds for the issuance of the writ at common law.
 [11] In People v. Reid, 195 Cal. 249 [232 P. 457, 36 A.L.R. 1435], the origin and office of the writ is treated at great length and the conclusions of this court are summed up by the following quotation from Sanders v. State, 85 Ind. 318 [44 Am. Rep. 29], with approval:
 "It is our opinion that the courts have the power to issue writs in the nature of the writ coram nobis, but that the writ cannot be so comprehensive as at common law, for remedies are given by our statute which did not exist at common law--the motion for a new trial and the right of appeal--and these very materially abridge the office and functions of the old writ. These afford an accused ample opportunity to present for review questions of fact, arising upon or prior to the trial, as well as questions of law; while at common law the writ of error allowed him to present to the appellate court only questions of law. Under our system all matters of fact reviewable by appeal, or upon motion, must be presented by motion for a new trial, and cannot be made the grounds of an application for the writ coram nobis. Within this rule must fall the defense of insanity as well as all other defenses existing at the time of the commission of the crime. Within this rule, too, must fall all cases of accident and surprise, of verdicts against evidence, of newly discovered evidence, and all like matters."
 The writ may be available in cases where a plea of guilty has been obtained from a defendant by some character of duress, or the trial has been affected by some outside force, such as reported in People v. Perez, 9 Cal.App. 265 [98 P. 870]; but clearly not in a case such as this, where both the defendant and his counsel, and the court, had full knowledge *150 of all the facts and acted in the light of these facts. The defendant is not complaining because his request was denied, but because it was granted. At the time the petition was filed herein there was a valid, subsisting judgment of conviction against the defendant and the court was without authority to annul it, so far as any right to do so is given by the so-called writ of error coram nobis proceedings.
 [12] At the conclusion of the hearing of the writ, the court being of the opinion that the plea of guilty of murder in the second degree given and entered May 9, 1910, was improperly made and entered, for the reason that the defendant had not been restored to sanity prior to making and entering said plea, vacated and set aside the judgment and the plea of guilty entered of record and, for the purposes of clearing the way and as grounds for further proceedings, ordered that, it appearing to the court that the defendant is still insane, he be examined by the sanity board of Contra Costa County on the following day. The formal proceedings as prescribed by section 2170 of the Political Code were adopted and the medical examiners found him to be very healthy both physically and mentally. He stated that he had suffered no headaches, hallucinations or delusions. When asked about his mental condition at the time his trial was suspended by the court and whether or not there was a probability of a recurrence of any mental trouble his answer was emphatically no, and he attributed his prior mental condition to "a severe mental shock at that time".
 There being not the slightest evidence of present or past insanity the court, upon the report and statement of the medical examiners, found the defendant sane. On the day appointed for rearraignment and taking the defendant's plea an order to show cause was directed by this court to said Superior Court of Contra Costa County to certify fully a transcript of the record and proceedings taken and had in said proceedings nullifying said judgment of conviction of James McFarland, to the end that all of the proceedings taken and had therein be annulled and adjudged void and of no effect; and further, pending the action of this court, that said superior court be restrained from further proceedings in said case of People of the State of California v. James McFarland, and that it show cause why the action taken by said court annulling said judgment of conviction should not *151 be canceled and said further proceedings in said case be terminated.
 The objection is made by respondent superior court that petitioner's only remedy was by appeal from said coram nobis order.
 It is true that the district attorney did state in open court at the time the court announced its order nullifying the judgment that he appealed from the order, but he did not prosecute the matter further, and adopted the method of certiorari. We are of the view that the order annulling the judgment is not the kind of order referred to in section 1237 of the Penal Code, which designates the cases in which an appeal may be taken. Under no fair construction can it be said (as in said section 1337 provided) that a proceeding such as instituted by the defendant herein can be regarded as an "order made after judgment, affecting the substantial rights of the party". It is not within the contemplation or intent of the section that such a proceeding, brought at the time and in the manner as shown herein, was to be classified with the orders made applicable "as an order made after judgment". This is a distinct proceeding and has no connection with any ruling made by the court during trial or any order since made by the court from which an appeal could have been taken. If an order from which an appeal could have been taken had as a matter of fact been made, the right to appeal therefrom has long since expired.
 The record in this case shows that the court acted in excess of its jurisdiction in annulling said judgment, which was valid upon its face and which was not vulnerable to the collateral attack made upon it. This has already been clearly shown. In such circumstances certiorari will lie. (Stanton v. Superior Court, 202 Cal. 478 [261 P. 1001], and cited cases.) The coram nobis judgment or order annulling the judgment of conviction of the defendant is void. Such a judgment may be set aside by the court at any time, and it is immaterial how the invalidity is called to its attention. The court will look to the substance of the application and the kind of relief sought and its action will be responsive to whatever relief may appear to be just in the premises, disregarding, where necessary, the name which the pleader has given his petition.
 We are of the view that the said superior court acted in excess of its jurisdiction in said matter and that its unauthorized *152 assumption of jurisdiction will not be permitted to void judgments regularly and legally entered. If, in the circumstances of the instant case, the judgment may be nullified on the showing disclosed by the record of the proceedings herein, the stability of judgments generally in criminal cases will be reduced to a dangerous state of uncertainty.
 The order vacating and setting aside the plea of guilty of the defendant to the crime of murder in the second degree, made in the Superior Court of the County of Contra Costa May 9, 1910, and the order purporting to annul the judgment of conviction of said defendant made and entered thereon May 12, 1910, are each annulled and set aside.
 Thompson, J., Shenk, J., Waste, C.J., and Preston, J., concurred.
