By a petition for a writ of habeas corpus filed on October 17, 1951, Caryl Chessman, an inmate of San Quentin State Prison whose appeal from 17 judgments of conviction was pending, sought relief from allegedly illegal conditions of imprisonment which assertedly interfered with his representation of himself.1 On December 18, 1951, this court affirmed the judgments, two of which imposed the death penalty. (People v. Chessman, 38 Cal.2d 166 [238 P.2d 1001].) The subject matter of Chessman’s petition for habeas corpus has no relevancy whatsoever to the proceedings at the trial which resulted in his conviction or to the legality of the judgments which were imposed and affirmed and under which he is now confined and awaiting execution; it relates solely *4to a matter of prison administration. After the judgments had been affirmed the superior court, in the habeas corpus proceeding, ordered that Chessman “continue to be allowed the free exercise” of asserted rights in connection with his representation of himself. The attorney general filed with the District Court of Appeal a notice of appeal from the superior court order; also, uncertain whether the People could appeal from the order, the attorney general filed with the District Court of Appeal a petition for a writ of review. The District Court of Appeal issued the writ of review. The matters have been transferred to this court, and Chessman has filed notices of motion to dismiss the review proceeding and the appeal. We have concluded, for reasons hereinafter stated, that the order appealed from should be reversed with directions to the superior court to dismiss the habeas corpus proceeding, and that the review proceeding should be dismissed.
Appealability of the Habeas Corpus Order
The principal ground of Chessman’s motion to dismiss the appeal is that the superior court order is not appealable. The People have asked that this court pass on the question whether they can appeal from an order on habeas corpus which directs that a petitioner be granted relief but which does not order his release from custody.
In accord with the view that ‘1 The right of appeal is derived from our constitution or statutes” (Gale v. Tuolumne County Water Co. (1914), 169 Cal. 46, 52 [145 P. 532]), prior to the enactment of section 1506 of the Penal Code in 1927 it was held that no orders on habeas corpus were appealable. (Matter of Perkins (1852), 2 Cal. 424, 430; People v. Schuster (1871), 40 Cal. 627; Matter of Hughes (1911), 159 Cal. 360, 363 [113 P. 684]; Matter of Zany (1913), 164 Cal. 724, 727 [130 P. 710]; France v. Superior Court (1927), 201 Cal. 122, 127 [255 P. 815, 52 A.L.R. 869]; Ex parte White (1906), 2 Cal.App. 726, 727 [84 P. 242].) Section 1506 of the Penal Code, as enacted in 1927, provided insofar as is here material that “An appeal may be taken ... by the people from a final order of a superior court made upon the return of a writ of habeas corpus discharging a defendant after his conviction, in all criminal cases prosecuted by indictment or information in a court of record. ...” There followed a series of eases which announced that the People could appeal only in those cases which came within the precise wording of the statute and refused to allow an appeal where the habeas corpus order *5was not made after conviction in a criminal case prosecuted by indictment or information. (In re Alpine (1928), 203 Cal. 731, 745 [265 P. 947, 58 A.L.R. 1500]; In re Bruegger (1928), 204 Cal. 169, 170 [267 P. 101]; Thuesen v. Superior Court (1932), 215 Cal. 572, 576 [12 P.2d 8]; Loustalot v. Superior Court (1947), 30 Cal.2d 905, 913 [186 P.2d 673]; In re Merwin (1930), 108 Cal.App. 31, 32 [290 P. 1076]; In re Dutton (1931), 119 Cal.App. 447, 448 [6 P.2d 558].)
Although in the last cited cases the court would not allow an appeal by the People except where there was literal compliance with statutory requirements that there be “conviction” in a case prosecuted “by indictment or information,” a liberal view as to the meaning of the word “discharging” in section 1506 was taken in In re Larabee (1933), 131 Cal.App. 261, 264 [21 P.2d 132]. There an inmate of San Quentin, confined pursuant to a judgment of conviction in Los Angeles County, sought habeas corpus in Marin County. By the superior court order in the habeas corpus proceeding petitioner was “remanded to the custody of the Sheriff of Los Angeles County.” The People appealed. Petitioner moved to dismiss the appeal on the ground that the order was not, in the language of section 1506 of the Penal Code, one “discharging” him. In denying the motion to dismiss, the appellate court said that the effect of the order was to discharge the petitioner from the custody of the warden, and the fact that the superior court also ordered petitioner remanded to the custody of the sheriff “did not have the effect of depriving the state of its right of appeal, for the reason that in the face of a valid commitment the trial court was without power to make such order. ’ ’
In 1951 section 1506 of the Penal Code was amended to provide that “An appeal may be taken ... by the people from a final order of a superior court made upon the return of a writ of habeas corpus discharging a defendant after his conviction in all criminal eases. ...” It is Chessman’s position that the order here is not appealable because it is not one “discharging” him. The People argue that as the uses of habeas corpus have been extended by judicial decision to the granting to prisoners of rights short of effecting their release from illegal custody, there should be a concomitant extension of appealability to orders effecting these new uses of the writ. The function of the writ of habeas corpus is solely to effect “discharge” from unlawful restraint, though the illegality in respect to which the discharge from restraint *6is sought may not go to the fact of continued detention but may be simply as to the circumstances under which the prisoner is held, as, for example, where he questions the propriety of his detention as an habitual criminal (In re McVickers (1946), 29 Cal.2d 264 [176 P.2d 40]; In re Seeley (1946), 29 Cal.2d 294, 299 [176 P.2d 24]; In re Harincar (1946), 29 Cal.2d 403 [176 P.2d 58]; In re Wolfson (1947), 30 Cal.2d 20 [180 P.2d 326]; In re Pearson (1947), 30 Cal.2d 871 [186 P.2d 401]) or where he questions the construction of the judgment of conviction under which he is held (In re Bramble (1947), 31 Cal.2d 43, 46, 51 [187 P.2d 411]). “Every person unlawfully imprisoned or restrained of his liberty, under any pretense whatever, may prosecute a writ of habeas corpus, to inquire into the cause of such imprisonment or restraint.” (Pen. Code, § 1473.) The scope of inquiry at the hearing on the writ includes consideration of “any fact to show either that his imprisonment or detention is unlawful, or that he is entitled to his discharge” (Pen. Code, § 1484) and “If no legal cause is shown for such imprisonment or restraint, or for the continuation thereof, . . . [the] court or judge must discharge such party from the custody or restraint under which he is held” (Pen. Code, § 1485), which means that the prisoner may be discharged from illegal conditions of restraint although not from all restraint. Since this is the function and scope of habeas corpus, we conclude that it is proper and desirable to interpret section 1506 of the Penal Code in its use of the word “discharging” as being fully as broad as the scope of the writ itself.
The People as Parties to the Appeal
It is Chessman’s position that the appeal should be dismissed because the People are not parties who can maintain such appeal. The People are not named as respondents in the petition for habeas corpus; the respondents there named are the warden, two assistant wardens, and the chief custody officer of San Quentin. However, authority for an appeal in the name of the People is found in section 1506 of the Penal Code which since its enactment has provided that an appeal may be taken “by the people” from certain orders on habeas corpus.
Availability of Certiorari to Review Superior Court Habeas Corpus Order
In support of his motion to dismiss the writ of certiorari Chessman contends that such writ will not lie to *7annul an order of the superior court on habeas corpus, no matter how erroneous it may be, if the superior court had “jurisdiction,” citing Matter of Hughes (1911), supra, 159 Cal. 360, 363. (See also Rose v. Superior Court (1948), 86 Cal.App.2d 173, 176 [194 P.2d 568].) However, we need not at this time reexamine the rationale of the Hughes case, or otherwise consider the grounds of dismissal urged by Chessman, because it follows as a matter of law from our conclusion that the remedy of appeal is available, that the writ of certiorari will not lie (Code Civ. Proc., § 1068), and, having been inadvertently issued, it will be-discharged and the proceeding will be dismissed (see Matter of Hughes (1911), supra, 159 Cal. 360, 366; Rose v. Superior Court (1948), supra, 86 Cal.App.2d 173, 178).
The Merits of the Superior Court Order
The original petition for habeas corpus dated October 3, 1951, alleges in pertinent part that Chessman has appeared and desires to continue to appear in his own behalf in his then pending appeal, and that he anticipates unjustifiable punishment, “depriving him of the use of books, typewriter, etc., on the pretext that he has violated a prison rule by helping another man prepare a legal document.” A supplement to the petition, dated October 7, 1951, alleges that the warden refused to have the original petition mailed to the superior court for filing; he returned it to Chessman with a notation that “I note that you anticipate that you are to receive some sort of punishment. I do not believe that any of us can look into the future and determine what will happen. I also note that you do not tell the truth throughout the petition.”, A further supplement, dated October 10, 1951, alleges that Chessman “is now confined in a ‘hole’ cell,” denied the use of “clerical supplies or legal books,” and “has only a few sheets of this paper and pen. ’ ’ The petition and the two supplements were filed on October 17, 1951.
The writ issued and pursuant to its command Chessman was produced before the superior court; respondent warden filed a return and moved that the matter be dismissed. Chessmen filed a traverse to the return in which he asked that the petition stand as partial traverse and averred that the prison authorities “continue to treat petitioner in such a way . . . as to deprive petitioner of his legal right effectively to litigate his case through the courts.”
Chessman, although under sentence of death, personally appeared at six hearings in the superior court between October *826, 1951, and March 7, 1952. The following facts were established: The delay in the filing of the original petition was due to the fact that the warden sent it to the attorney general with a request for advice as to whether he should mail it to the court for filing; the attorney general advised that the warden should permit its filing. On October 9, 1951, the prison disciplinary committee found that Chessman had violated a prison rule by aiding another inmate and punished him by a reprimand; also on October 9, 1951, Chessman created a loud disturbance and for this he was summarily punished by confinement in a “quiet cell,” without typewriter, books, or his papers, from October 10 to 15, 1951. On October 16, 1951, the disciplinary committee found Chessman guilty of disorderly conduct and he was punished by confinement to his own cell for 10 days. On October 26, 1951, Chessman first appeared in the superior court in the habeas corpus matter, the facilities which had been given him in connection with his representation of himself had been restored to him, and he admitted that the question of the deprivation of such facilities “in the abstract ... is moot.”
During the course of the hearings Chessman wrote to Mr. Garry, attorney of record for another prisoner, that he wished to see Mr. Garry; Mr. Garry called at the prison to talk with his client, then asked to see Chessman; an assistant warden informed Mr. Garry that he could not see Chessman because he was not attorney of record for him. Mr. Garry sat with Chessman at the counsel table as “legal advisor” during one of the hearings on the habeas corpus matter.
The superior court ordered that the warden’s motion to dismiss be denied and that Chessman “be remanded to the custody of the Warden . . . with directions that the said Petitioner continue to be allowed the free exercise of the following legal and constitutional rights:
“ (1) That the said Petitioner be allowed immediate access by mail to the courts of this State and of the United States at all times;
“ (2) That the said Petitioner be allowed to make all reasonably necessary legal research for, and to prepare and file with any such court, any document he deems necessary to the maintenance of protection of his civil rights or to the effective representation of himself on appeal from, or in collaterally attacking, any or all of those judgments of conviction under which the. Respondent Warden derives his legal authority to hold the said Petitioner in custody.
*9“ (3) That the said Petitioner be allowed to retain his personal legal papers and books at all times during which he may reasonably make use of them for the purposes hereinabove set forth.
‘1 (4) That while so representing himself on appeal or in collaterally attacking any or all of those said judgments of conviction, the said Petitioner should be allowed privately to consult with attorneys of his own choosing and to consult and communicate with other responsible persons, so long as the said Petitioner and those who confer with him at the prison or communicate with him upon legal matters comply with the Rules and Regulations of the Prison respecting such activities. ’ ’
The writ of habeas corpus has been allowed to one lawfully in custody as a means of enforcing rights to which, in his confinement, he is entitled. It has been held that a prisoner is entitled to, and habeas corpus is available to enforce, “the right to file in any court a petition or other document which purports to seek some remedy or relief relating to the offense for which he was imprisoned” (In re Robinson (1952), 112 Cal.App.2d 626, 629 [246 P.2d 982]; In re Malone (1952), 112 Cal.App.2d 631 [246 P.2d 984]; see Ex parte Hull (1941), 312 U.S. 546, 549 [61 S.Ct. 640, 85 L.Ed. 1034]) and petitioner’s right, at reasonable times, to consult privately with his counsel in preparation for trial (In re Rider (1920), 50 Cal.App. 797, 799 [195 P. 965]; In re Snyder (1923), 62 Cal.App. 697, 699 [217 P. 777]; In re Qualls (1943), 58 Cal.App.2d 330, 331 [136 P.2d 341]).
The present order cannot be upheld as one enforcing such rights, for at the time of the hearings and the making of the order Chessman was not being deprived of those rights. The petition for habeas corpus had been filed and the delay preceding its filing was no longer a ground for complaint. Aside from the fact that the warden temporarily took the erroneous position that he could refuse to permit the filing of the petition for habeas corpus, no violation of any right to which a prisoner is entitled was made to appear. The temporary separation of Chessman from his papers was shown to have been an incident of punishment for his violation of a reasonable prison rule against the creation of loud disturbances. The refusal to permit him to see Mr. Garry was shown to have been based on the reasonable ground that Mr. Garry was not his attorney. It is manifest from the *10entire record of this habeas corpus proceeding that Chessman is claiming not rights but special privileges. As the court which tried him and this court have previously had occasion to point out, Chessman’s decision to represent himself did not entitle him to greater privileges than other prisoners. (See People v. Chessman (1951), supra, 38 Cal.2d 166, 173-174, 176.)
When it developed at the hearings that Chessman was not then being deprived of rights to which he as a prisoner was entitled, the superior court should have granted the People’s motion to dismiss. Instead it made an order which purports to declare that Chessman “continue to be allowed” privileges which are not enforceable rights of prisoners. For example, it would be manifestly impossible to allow prisoners “immediate access by mail to the courts ... at all times. ” As indicated above, prisoners have the right to prompt and timely access to the mails for the purpose of transmitting to the courts statements of facts which attempt to show any ground for relief, but they have no legally enforceable rights to engage in legal research.2 Since it has not been shown that Chessman was being deprived of any rights at the time of the making of the superior court order, and since that order purports to declare that he is to be allowed future privileges to which he is not entitled, the order cannot be upheld.
For the reasons above stated, the motions of Chessman are denied; the writ of review is discharged and the review proceeding is dismissed; the order on habeas corpus is reversed and the cause on habeas corpus is remanded to the superior court with directions that the writ be discharged, the petitioner be remanded to the custody of the warden, and the proceeding be dismissed. Let the remittiturs issue forthwith.
Gibson, C. J., Shenk, J., and Spence, J., concurred.
Edmonds, J., and Traynor, J., concurred in the judgment.
Petitioner continued to represent himself in these proceedings until November 8, 1954, when Mr. Berwyn Rice was appointed to represent him. On November 24, at Chessman’s request, the appointment of Mr. Rice was terminated. At oral argument Miss Rosalie Asher appeared for Chessman.
“A person sentenced to death is deemed civilly dead during the existence of the death sentence. ’ ’ (Pen. Code, § 2602.) Also, because Chessman is under sentence to life imprisonment he is deemed civilly dead (Pen. Code, § 2601) and because he is under sentence to imprisonment for terms less than' life his civil rights are suspended (Pen. Code, $ 2600).