
16 Cal.2d 593 (1940)
BELMORE BROWNE, as Guardian, etc., Petitioner,
v.
THE SUPERIOR COURT OF THE CITY AND COUNTY OF SAN FRANCISCO et al., Respondents.
S. F. No. 16352. 
Supreme Court of California. In Bank.  
November 12, 1940.
 Freitas, Duffy & Keating for Petitioner.
 Harold V. Daley and Abbott, Appel & Dains for Respondents.
 GIBSON, C.J.
 This is a petition for a writ of prohibition, to restrain respondent superior court from hearing and deciding an application for a writ of habeas corpus sought on behalf of an incompetent person.
 The petition shows that Mrs. Ella H. Browne, an elderly lady nearly ninety years of age, was adjudged incompetent in a proceeding in the Superior Court of Santa Barbara County. On April 23, 1934, her son, Belmore Browne, petitioner herein, was appointed guardian of her person and estate. He qualified as such and entered upon his duties.
 Mrs. Browne remained in Santa Barbara until October, 1936. At that time, upon the advice of physicians, including psychiatrists, she was sent to San Francisco and placed in the Greer Home, an institution offering satisfactory care and attention. Thereafter J. W. Browne, another son, in various communications to his mother and to the guardian, urged that she come back to Santa Barbara. Her attending physician opposed the move as dangerous. On November 22, 1937, the guardian filed a petition in the Santa Barbara Superior Court seeking instructions, in which all of the foregoing facts were set forth. The court held a hearing at which J. W. Browne failed to appear, and entered its order instructing the guardian that the ward should remain in San Francisco at the nursing home, and that her attending physician should examine and if necessary censor her incoming mail for the purpose of avoiding undue excitement.
 J. W. Browne then moved to reopen the case, and the court did so. At this hearing the parties, including J. W. Browne, stipulated that the matter be submitted upon the testimony of *596 a psychiatrist appointed by the court. This psychiatrist testified that Mrs. Browne was sane, but mentally childish and incapable of making practical judgments alone; that her age, and her physical and mental condition made it dangerous to move her to Santa Barbara, for the reason that the excitement incident thereto might bring on a fatal heart attack; that the Greer Home furnished good service and environment well adapted to her needs, and that there was no nursing home in Santa Barbara comparable in service and price; that her desire to return to Santa Barbara was merely a normal result of her age and condition, but that it was not safe for her to do so. On the basis of this evidence the court reaffirmed its original order instructing the guardian to keep Mrs. Browne in San Francisco. No appeal was taken from either order.
 On April 7, 1939, Harold V. Daley, the attorney who had represented J. W. Browne in the earlier proceedings, made an application in the San Francisco Superior Court for a writ of habeas corpus on behalf of Mrs. Browne. The application alleged that he was her attorney and was requested by her to institute the proceeding to release her from restraint; that she was being unlawfully confined in the Greer Home by her guardian and the superintendent and doctor; that her confinement was unlawful for the reason that she was not insane or mentally unsound; that conditions and associations in Santa Barbara were more conducive to her happiness; that her entreaties to her guardian to be returned there had been disregarded, leaving her homesick and unhappy; that her estate was sufficient to provide such institutional care as might be proper upon her return to Santa Barbara; and (on information and belief) that she could make the journey without danger. It was further alleged that because of the censorship of her mail and visitors, her attorney was unable to discuss her case freely and for this reason presented the application on her behalf without verification by her. The prayer was "that said Ella H. Browne be relieved of and from such detention, confinement and restraint and for such other and further relief as she ought to have".
 The writ issued, and a demurrer and answer were filed, denying most of the material allegations and raising mainly the issues of jurisdiction and res judicata. The demurrer was overruled and the court set the proceeding in habeas *597 corpus for trial. Thereupon petitioner sought a writ of prohibition in this court, and an alternative writ issued.
 [1] A preliminary objection made by respondents is that prohibition can only issue to an inferior tribunal, and that in its jurisdiction to issue habeas corpus the superior court is on the same plane as an appellate court. This argument is answered by cases recognizing the power to restrain unauthorized issuance of habeas corpus. (France v. Superior Court, 201 Cal. 122 [255 P. 815, 52 A.L.R. 869]; Bartlett v. Superior Court, 108 Cal.App. 755 [292 P. 545]; 29 C.J., 116; 12 R. C. L. 1218.) Under these authorities there can be no doubt of our power and duty to grant the writ of prohibition herein if the respondent superior court is acting in excess of its jurisdiction.
 [2] The chief contention of petitioner is that the Santa Barbara court has exclusive jurisdiction over the custody of the incompetent, and that the San Francisco court has no power to interfere with it. This is the familiar proposition that where several courts have concurrent jurisdiction over a certain type of proceeding, the first one to assume and exercise such jurisdiction in a particular case acquires an exclusive jurisdiction. Thereafter another court, though it might originally have taken jurisdiction, is wholly without power to interfere, and may be restrained by prohibition. (See Gorman v. Superior Court, 23 Cal.App.2d 173 [72 PaCal.2d 774].) The rule is generally invoked where a proceeding is still pending; when it is completed and judgment has become final, jurisdiction has been exhausted and the rule has no application.
 [3] In applying this doctrine to a guardianship proceeding, we must keep in mind at least two distinct stages in the court proceedings. First there is the petition brought to establish the incompetency of the ward and to obtain the appointment of a guardian. When this matter is concluded, the second stage is reached, wherein the guardian undertakes the duties of providing for the ward and administering his affairs. As to the first stage, the determination of incompetency and resulting appointment of a guardian, the issues are no longer pending. A final adjudication has been made. In the present case the jurisdiction of the Santa Barbara court over this subject matter has been fully exercised, and for all normal purposes this adjudication is conclusive. If the question of incompetency may properly be raised again, *598 there is no longer any objection that the matter is pending within the jurisdiction of the Santa Barbara court.
 As to the second stage, however, the matter is not concluded until the discharge of the guardian. In carrying out his duties of administration he acts under the authority and supervision of the court which appointed him, must render accountings, may petition for instructions, and is subject to liability or removal for misconduct. The jurisdiction of the court in this respect is a continuing one, and though no motion, petition or other such incidental proceeding may be pending at any particular time, the court still has jurisdiction over the guardianship. No other court, we believe, has power to interfere with that continuing control over the guardian; no other court could receive and approve his accounting, or instruct him as to his duties. The San Francisco Superior Court cannot, in this habeas corpus proceeding, enter into any consideration of the propriety of the medical or other care of Mrs. Browne, her residence, the extent of supervision over her visitors, mail or other personal activities, or any other matters connected with her guardianship. The allegation that she desires to return to Santa Barbara has no legal significance under the facts recited; no more significance, indeed, than her personal preference as to doctors, drugs or treatment. Under the law her guardian must choose her place of residence (Prob. Code, sec. 1500), and the Santa Barbara court has fully considered all matters pertaining thereto. These are all wholly within the jurisdiction of the Santa Barbara court, and are beyond the scope of any proceeding in habeas corpus. [4] Ordinarily, the court in a habeas corpus proceeding of this kind can have but one issue to determine: Whether the applicant is being unlawfully deprived of liberty. If she is competent, she should be freed from all custody and may choose her own residence and mode of life. If she is incompetent, she is properly in the custody of her guardian and is not entitled to a discharge.
 [5] It remains now to test the present proceeding by these principles. The application for the writ of habeas corpus contains allegations of illegal restraint of a competent person, which, standing alone, would doubtless give jurisdiction to the court to determine her competency and right to release from restraint. But there are statements in the pleadings and briefs which throw an entirely different light *599 upon the proceeding. The petition for prohibition alleges that by the application for habeas corpus "it is sought to free said ward from the custody of her guardian". In the answer to the petition, filed by the attorneys who obtained the writ of habeas corpus, they "Deny that by the application of Ella H. Browne for writ of habeas corpus it is sought to free said Ella H. Browne from the custody of her guardian." And in one of their briefs, said counsel state: "Her petition for habeas corpus in the San Francisco Superior Court seeks her removal to Santa Barbara."
 Because of this confusion, counsel at the oral argument were questioned as to the real object of the application. At that time counsel for the applicant denied any intention of seeking the release of the ward from custody or having the guardian removed, and stated that the purpose was, first, "to enable this ward to have a certain measure of freedom, using that term in the sense of a desire on her part to be permitted to return to Santa Barbara"; second, "to remedy unreasonable restraint upon her personal liberties with respect to the improper, as we contend, censorship of her mail and also the denial to her of the right to have visitors come to her at the Greer Home, where she was in effect kept incommunicado by her guardian". These statements constitute an abandonment of the only proper ground upon which the writ could issue. The action of the respondent court in issuing its writ of habeas corpus was undoubtedly based upon a misconception of the object of counsel who applied for it. The subsequent disclosures show that the matters sought to be determined, namely, the residence and method of treatment of the ward, are exclusively within the jurisdiction of the Santa Barbara court, and outside the scope of the writ of habeas corpus. If these facts had been brought to its attention, the lower court might properly have dismissed the proceeding. It is equally proper for this court to grant prohibition to restrain it.
 [6] Counsel for the applicant, it is true, makes some attempt to justify the use of the writ of habeas corpus to remedy what he describes as the "unreasonable restraint upon her personal liberties", consisting of the designation of San Francisco as her residence, and the limitations placed upon her right to receive mail and visitors. He has furnished us with no case in point, but relies on a few general statements to the effect that unreasonable interference with the personal *600 liberty or welfare of a person may be inquired into on habeas corpus, notwithstanding the fact that the person is in the custody of a guardian. The case of State ex rel. Raymond v. Lawrence, 86 Minn. 310 [90 N.W. 769, 58 L.R.A. 931], offers a typical illustration of the meaning of these statements. The court there declared that "The welfare of the ward is the chief matter to be considered--not the wishes of the relatives, nor the convenience of the guardian. ... The guardian does not have unlimited power over the ward, and cannot change its temporary or permanent residence to its detriment ..." Further on, the court said: "Where an attempt is made by a guardian or anybody else to exercise any restraint over the person of anyone within this state, the writ of habeas corpus, or any other appropriate remedy, will always be effectual to inquire into the propriety of any such attempted restraint, and upon such inquiry the proper court can make such an order or judgment as the particular case may require." However, a study of the opinion reveals that the guardians were actuated by personal hostility to the relator, daughter of the ward, and gave "scant consideration" to the welfare of the ward. Notwithstanding this misconduct, the court held that, until removed by the probate court, the guardians could care for and control the ward in any reasonable manner. "They may designate the persons in whose immediate charge she shall be,--such as the attending physician and nurses,--and may insist upon the observance of reasonable rules and regulations conducive to her health and comfort." Accordingly, the court declined to approve an attempt by the lower court commissioner to make a change in her custody and control, but reaffirmed the rule that these matters were within the sound discretion of the guardians.
 Such decisions are entirely reasonable when considered in connection with their particular facts. We may assume that if the guardian of the incompetent herein, without instruction or authorization from the court, took the ward away from her home to an unsatisfactory place of residence, or unjustifiably confined or imprisoned her so as to deny her the pleasures of visiting her family or friends, or deprived her of the opportunity to receive medical care by preventing her from seeing a physician, these restraints might, in the absence of another adequate remedy, be the subject of inquiry on habeas corpus. The guardian has the custody and care of the ward, but the ward is not his prisoner. He may limit *601 her activities in a reasonable manner, for her own benefit, but cannot, without good reason, deny her such freedom as is essential to her welfare.
 [7] All this, however, has no bearing on the instant case. The guardian is not arbitrarily confining or limiting the freedom of the ward upon his own initiative. He is acting under the instructions of the court having jurisdiction of the guardianship, and the court gave those instructions after the fullest possible hearing, and upon ample and practically conclusive testimony that the particular course of conduct prescribed was for the best interests of the ward. The court may have been wrong then, and it may be wrong now. For the error it may have committed then, appellate review was possible. For the error it may be committing now, an application to that court, which has continuing jurisdiction of the guardianship, is still possible. Evidence as to the condition, the needs and the desires of the ward may be presented to that court on her behalf, and the fairness of the hearing or the correctness of the decision may be reviewed on appeal. But in the present circumstances there is no possible ground for habeas corpus. There is no illegal restraint whatever. Everything has been done in accordance with the lawful orders of a court with jurisdiction to make them, upon evidence which fully supports the orders. If the guardian were to permit what the application demands, he would be acting in violation of the orders of the Santa Barbara court, and would be answerable to that court for his misconduct.
 [8] The only other contention that requires consideration is that the writ may issue to permit the incompetent to consult with her attorney, a right now alleged to be denied her. There are, of course, authorities which hold that the right of an accused or a prisoner to consult his counsel may be enforced on habeas corpus (see In re Rider, 50 Cal.App. 797 [195 P. 965]), but we are unable to see any relevancy in those decisions. The present application for habeas corpus was filed by Harold V. Daley, who was attorney for the brother of the guardian, but who never, as far as the record shows, represented the ward. However, even granting his authority, his right to do so has never been denied. The Santa Barbara court, which, as we have seen, is the only court having jurisdiction to consider the matters raised in the present proceeding, has never refused to hear an application *602 on behalf of the ward, by Mr. Daley or any other attorney. The proper place to enforce his alleged right to consult the ward is, in the first instance, the Santa Barbara court. But the record fails to show any attempt to seek relief there. On the contrary, it was expressly admitted at the oral argument that this was not done. We cannot assume that the Santa Barbara court will deny a request which has never been made.
 Let a peremptory writ of prohibition issue restraining respondent superior court from trial or determination of the issues raised by the application for habeas corpus.
 Curtis, J., Edmonds, J., and Moore, J., pro tem., concurred.
 CARTER, J.,
 Concurring.
 I concur in the conclusion reached in the opinion prepared by the chief justice. In my opinion the Superior Court of Santa Barbara County had exclusive jurisdiction over all matters pertaining to the person and estate of the alleged incompetent person and was pursuing its jurisdiction in directing her guardian as to where and in what manner his ward should be maintained. The Superior Court of Santa Barbara County is open to the ward or anyone interested in her personal or financial welfare to seek a modification of the restrictions imposed upon the guardian for her maintenance, and anyone applying for a modification of said order has the right of appeal from any further or additional orders made by said Superior Court.
 While it is true that the Superior Court of the City and County of San Francisco has jurisdiction to issue a writ of habeas corpus to anyone unlawfully detained within the city and county of San Francisco, such jurisdiction cannot be exercised to nullify an executory order made by the Superior Court of Santa Barbara County in a proceeding clearly within the jurisdiction of the latter court.
 It is obvious that the granting of the writ of habeas corpus prayed for in the case at bar would result in an absurdity; that is, assuming that the Superior Court of the City and County of San Francisco granted the writ of habeas corpus prayed for, which would have the effect of releasing the incompetent person from the control of her guardian in San Francisco so that she could return to Santa Barbara county; such return would be in violation of the order made by the Superior Court of Santa Barbara County, and the latter *603 court would undoubtedly order the guardian to return the ward to the Greer Home in San Francisco; this would be in violation of the writ of habeas corpus issued out of the Superior Court of the City and County of San Francisco. The effect of each of these courts persisting in having their respective orders and writs executed would result in making a shuttle-cock out of the ward without either party being able to obtain relief by appeal, since the order instructing the guardian with respect to the maintenance of the ward has become final, and the order granting the writ of habeas corpus is not appealable.
 To my mind the same rule should be applied here as was applied in the case of Gorman v. Superior Court, 23 Cal.App.2d 173 [72 PaCal.2d 774], where it was held that the court first obtaining jurisdiction over the subject matter of an action and the parties thereto, had exclusive jurisdiction to proceed with the disposition of the action, and that a court of concurrent jurisdiction in which the same action was subsequently commenced should be restrained by a writ of prohibition from proceeding with the disposition of the case until the first Superior Court had exhausted its jurisdiction.
 The instant case is not one where the Superior Court of Santa Barbara County has made a final determination of the subject matter of the proceeding before it, and thereby exhausted its jurisdiction, as said court still retains jurisdiction of said proceeding to enforce its order relating to the maintenance of the ward; such order is subject to modification from time to time by the Superior Court of Santa Barbara County, and there appears to be no question but that the interests of the ward will be amply safeguarded by permitting the Superior Court of Santa Barbara County to exercise exclusive jurisdiction in determining the place where and the manner in which said ward shall be maintained by her guardian.
 I think it is obvious that a writ of prohibition should be granted restraining the Superior Court of the City and County of San Francisco from proceeding further with the habeas corpus proceeding therein.
 SHENK, J.,
 Dissenting.
 I dissent.
 It should be borne in mind that this is not a proceeding to restrain the superior court from passing upon the application for a writ of habeas corpus. That application had in *604 fact been passed upon and the writ had issued before the present proceeding was commenced. The main opinion states that the writ had issued, but much of it proceeds on the theory that it had not, and consequently that the respondents in that proceeding need not be put to their proof in justification of the alleged unlawful restraint. The concurring opinion definitely proceeds on the mistaken assumption of fact that the writ had not been issued. That the petition for the writ of habeas corpus stated a prima facie case when it was presented to the respondent court cannot be denied. That it did not purport to demand a release of the ward from the custody of the guardian was fairly disclosed on the face of the petition and was also freely conceded by counsel for the petitioner on oral argument herein. The obvious purpose of the habeas corpus proceeding was and is to have the respondent court define the rights of the ward under the facts to be disclosed at the hearing on the return to the writ. How the concession of counsel for the petitioner as to the limited purpose of his application would constitute "an abandonment of the only proper ground upon which the writ could issue" is beyond my comprehension. To so declare is to deny the right to resort to habeas corpus to define rights and obtain relief less than complete discharge.
 The matter before the respondent court which has been stopped by this court was a hearing on the issues framed by the allegations of the petition for the writ of habeas corpus and the return thereto. The majority has proceeded to decide the merits of that controversy in a proceeding in prohibition. It cannot be assumed, as the majority seem to do, that the respondent court will disregard the showing on the return to the writ of habeas corpus and arbitrarily decide the matter before it contrary to the law and the facts there presented. It is certain that issues of both law and fact would be presented to that court on the hearing. Those issues were raised by the petition for the writ of habeas corpus wherein it was alleged that on or about the 23rd of April, 1934, the Superior Court of the State of California, in and for the County of Santa Barbara, made and entered an order appointing Belmore Browne as guardian of the person and estate of the petitioner, an alleged incompetent person; and that Belmore Browne has since been and still is acting as such guardian; that the applicant Ella H. Browne is now and for several years last past has been unlawfully *605 and improperly restrained of her liberty and confined and detained at the Greer Home, located at No. 6000 Fulton street, in San Francisco, by said guardian and certain named persons acting in concert with and at the direction of said guardian; that the restraint of applicant's liberty and the confinement and detention of her person by said persons are unlawful, and in that respect alleges as follows: (1) That while of advanced years, she is not and never has been insane or mentally unsound, is a person of high cultural background, refinement and education, and possesses mental capacity to fully comprehend and distinguish her environment and residences which she has voluntarily chosen and which afford her happiness and contentment; (2) that for more than twenty years before the appointment of said guardian the applicant maintained her home in Santa Barbara, where she now owns a residential dwelling, where she has friends of long standing whose company and association she enjoys and desires; (3) that since his appointment as guardian, said Belmore Browne, on or about October 18, 1936, removed her from Santa Barbara to San Francisco and placed her in said Greer Home, where she has since been continuously confined, detained and restrained of her liberty, against her wishes and without her consent and in utter disregard of her entreaties to be returned to Santa Barbara; that by reason of her guardian's disregard of her wishes to be so returned, she continues to remain homesick, unhappy, discontented and distressed; (4) that the estate of the applicant is amply sufficient to meet all expenses incident to her return to Santa Barbara and her proper care and maintenance in that city during the remainder of her life; (5) that reputable physicians and psychiatrists have examined the applicant and have advised that she can make the journey to Santa Barbara without danger or harm to her health or physical well being and that the change will be of extreme benefit to her; (6) that in refusing to effect applicant's return to Santa Barbara and in causing her to be detained, confined and restrained of her liberty at the Greer Home in San Francisco, her guardian is acting arbitrarily, improperly, unreasonably and unlawfully and in abuse of the spirit and intent of the powers conferred upon him as such guardian, and without any respect, regard or consideration for the welfare, comfort and happiness of the applicant; (7) that without just cause the guardian and those acting *606 in concert with him have accomplished strict and complete censorship of all the correspondence to and from the applicant, including her letters to her son John W. Browne and his letters to her, and do likewise interfere with and violate confidential and personal communications passing between applicant and her attorney herein; (8) that her guardian, with the aid and assistance of those acting in concert with him, and without just cause, has refused to allow applicant to be visited by her friends of long standing, notwithstanding the fact that such visits would have brought much happiness to the applicant and could in nowise be detrimental to her health and well being, and has refused to allow petitioner, her attorney, to visit with her and discuss with her matters concerning her personal affairs, her confinement and restraint of her liberty.
 The petitioner prayed that the court issue the writ of habeas corpus directing the persons named, having her in custody, "to have the body of said Ella H. Browne thus confined and detained and restrained of her liberty, as aforesaid, before said court, at a certain time and place therein to be specified, to do and receive what shall then and there be considered concerning said Ella H. Browne together with the time and cause of her detention and restraint, and said writ; and that said Ella H. Browne be relieved of and from such detention, confinement and restraint and for such other and further relief as she ought to have".
 Upon the filing of the aforesaid petition the respondent court issued a writ of habeas corpus returnable at a specified time and place. As a return to the writ the respondents in said proceeding filed a demurrer to the petition and also an answer, in which it was denied that the applicant was unlawfully restrained of her liberty and in which it was alleged that the matters sought to be adjudicated in the habeas corpus proceeding in the Superior Court in and for the City and County of San Francisco had been presented to the Superior Court of Santa Barbara county and had "been adjudicated by said superior court, as more fully appears from the record of proceedings on file with said court", which proceedings are described and referred to in said answer with certain exhibits attached.
 When the matter came on for hearing before the respondent court on the return to the writ, the guardian interposed *607 an objection to the court's proceeding further to hear and determine the matter on the ground that said court was without jurisdiction in the premises for the reason that the Superior Court in and for the County of Santa Barbara "has acquired and is exercising jurisdiction in all things and matters pertaining to the guardianship of the person and estate of Ella H. Browne, an incompetent person", and that all such matters should be addressed to the court in Santa Barbara county.
 The respondent court overruled the objection and the present proceeding was brought to prohibit that court from further hearing or making any determination in the habeas corpus proceeding.
 The conceded purpose of the habeas corpus proceeding is (1) to test the right of the guardian to confine the ward in the Greer Home in San Francisco under the circumstances alleged; (2) to test the right of those having custody of the ward to censor her mail and deprive her of the privilege of having her friends visit her; and (3) to test the right of the guardian and those acting for him to prevent the ward from consulting with her attorney.
 As to the liberties enumerated and sought to be protected, it must be said that the petition states a prima facie case in favor of the issuance of the writ. "The office of the writ is to afford the citizen a speedy and effective method of securing the removal of any unlawful restraint upon his liberty; and the statute which confers the right has always been construed in favor of the liberty of the citizen." (In re Rider, 50 Cal.App. 797 [195 P. 965].) The guardian does not have unlimited power over the ward, even though the ward be an incompetent person. (State ex rel. Raymond v. Lawrence, 86 Minn. 310 [90 N.W. 769, 58 L.R.A. 931].) It was held in that case that where an attempt is made by a guardian of an incompetent to exercise any restraint over the person of the ward, "the writ of habeas corpus ... will always be effectual to inquire into the propriety of any such attempted restraint". On the same subject and commenting on that case and authorities to like effect, the author of the article on Habeas Corpus in 25 American Jurisprudence, at page 209, says: "An attempt made by the guardian of the person of an incompetent to exercise any unauthorized restraint over such person can be frustrated by a writ of habeas corpus, but *608 the relief which may be granted under such a writ does not include an order removing the guardian and depriving him of all authority over the person of the incompetent; such an order can be made only in the guardianship proceeding."
 It needs no citation of authority to support the assertion that the right of the ward to dispatch and receive her mail is prima facie one of the liberties which may be protected from unlawful interference. Her right to consult with an attorney concerning her alleged unlawful restraint would likewise appear prima facie to be subject to such protection. There is nothing on the face of the petition which would deprive the applicant of the right to apply for the writ and the prima facie showing therein made was sufficient to warrant the issuance thereof.
 It may well be that upon a hearing on the return to the writ full and complete justification for the alleged unlawful restraint would be established by the records of the proceedings in the Santa Barbara court. The record of those proceedings, brought before the court as a part of the return to the writ of habeas corpus, is defensive in character and might well operate in justification of the alleged unlawful restraint. Matters of justification do not go to the jurisdiction of the respondent court to consider the issues presented by the return to the writ.
 The respondent court should be permitted to hear and determine the habeas corpus proceeding: First, because the right to resort to habeas corpus as against unlawful restraint of personal liberty or freedom of action is firmly grounded in the law, both constitutional and statutory. The essential object and purpose of the writ are to inquire into all manner of involuntary restraints. This writ has long been regarded as the greatest remedy known to the law whereby one unlawfully restrained of his liberty may secure release or have his civil rights defined. Its origin is obscured in antiquity. It antedated Magna Charta, and the right to resort to it is universally recognized in English and American law. The Constitution of the United States (art. I, sec. 9) provides: "The privilege of the writ of habeas corpus shall not be suspended, unless when in cases of rebellion or invasion the public safety may require it." Article I, section 5, of our state Constitution, makes the same provision. Although these constitutional mandates are generally directed to the legislature or *609 executive departments, or both (25 Am. Jur., p. 149) the protection of the fundamental right there declared has been enjoined on the court. In this state, section 1473 of the Penal Code provides: "Every person unlawfully imprisoned or restrained of his liberty, under any pretense whatever, may prosecute a writ of habeas corpus, to enquire into the cause of such imprisonment or restraint." Under that and the succeeding sections of the same code, any person deeming himself unlawfully restrained of his liberty has the right to apply to a court of competent jurisdiction for the issuance of the writ and to have a ruling thereon. The ruling may be in the form of an order denying the writ for failure to state facts justifying its issuance. Having issued it, as here, the question then is whether the return thereto shows lawful justification for the restraint, and the petitioner is just as much entitled to have the court rule upon the sufficiency or insufficiency of the return as he is to have a ruling on his application for the issuance of the writ.
 Secondly, the superior court has constitutional jurisdiction to issue the writ of habeas corpus (art. VI, sec. 5). The consideration of and ruling on the petition for the writ is ordinarily ex parte. "After a return to a writ, the court or judge to whom the return is made must pass upon all questions of both law and fact and determine the ultimate questions whether the prisoner is wrongfully restrained of his liberty. It is necessary for the court to determine the weight and credibility of the evidence where the testimony is conflicting." (25 Am. Jur., p. 245, and authorities there cited.) When the applicant is rightfully in custody the hearing on the return may disclose a partial unlawful restraint, or no unlawful restraint at all. In the pending habeas corpus proceeding the respondent court may conclude that the alleged illegal restraints are justified by reason of prior adjudications in Santa Barbara county, or are justified by reason of the present mental and physical condition of the applicant. These questions should be determined by the respondent court in its consideration of the issues raised on the return to the writ, and its constitutional and statutory power so to do should not be interfered with in the present proceeding.
 Marks, J., pro tem., concurred.
