
32 Cal.2d 73 (1948)
In re ALBERT WILLIE McCOY, on Habeas Corpus.
Crim. No. 4819. 
Supreme Court of California. In Bank.  
June 15, 1948.
 John C. Henderson for Petitioner.
 Fred N. Howser, Attorney General, Clarence A. Linn, Deputy Attorney General, Ralph E. Hoyt, District Attorney (Alameda), and Thomas J. Buckley, Deputy District Attorney, for Respondent.
 EDMONDS, J.
 Albert Willie McCoy pleaded guilty to a misdemeanor charge and was sentenced to a term in the county jail. This court granted a writ of habeas corpus upon his petition which alleged that he was denied counsel and not advised of his legal rights. The State concedes that the judge of the police court by whom he was sentenced did not inform McCoy as to his right to counsel. By stipulation, the other issues have been submitted for decision upon affidavits, the prior testimony of McCoy, and certain other persons.
 In an affidavit, McCoy states that, after his arrest upon a Saturday night, he asked the officer, who was operating the elevator in the Oakland city jail, if he could "get in touch with his people." The officer said "No." He noticed some *75 of the prisoners using the telephone, and asked one of the jailors if he could "call some of his people, so they could get him a lawyer." The jailor refused to let him do so. Between the time he was placed in jail and the following Monday morning when he was taken before a police judge for arraignment, he asked "at least three different jailors could he call out or write a letter to his folks, so they could get him a lawyer." In each instance, permission was refused and the last jailor to whom he spoke told him he could not telephone or write a letter until after he appeared in court.
 On Monday morning, enroute to the court, he asked the officer in charge of him for an attorney and was told that he could not get one "until he went back upstairs [to the jail]." In court, the clerk read the complaint to him and "he again said in a soft voice to the officer, couldn't he get a lawyer; the officer motioned him to keep quiet, and said 'answer the Clerk'; the Clerk in the meantime had asked affiant, was he guilty or not guilty; the Clerk again repeated the question, and affiant answered in the affirmative; the officer motioned affiant to return to the prisoner's dock, and as affiant started to same, he again asked the officer, could he get a lawyer, and said officer, as he nudged affiant to speed him back in the stock, replied that affiant could get a lawyer when he got out."
 After these proceedings, the affidavit concludes, in the city jail, before he was taken to the county jail, he asked the officer, who later took him there, if he could get a lawyer. This officer took him to a desk and he was shown a yellow sheet with the names of a number of lawyers on it, and he "was told to sign a slip for the lawyer he wanted." He picked the name of one of them "at random" and immediately after signing the request he was taken to the county jail. He never heard from nor saw the lawyer whose name he selected. He had not been arrested before and knew nothing about jail rules.
 By affidavit the chief jailor explained the general custom of the institution. He declared that during the time when McCoy was in custody "no prisoner who requested an attorney was denied an opportunity to obtain the services of an attorney; that all prisoners are informed that those desiring the services of an attorney may request the same by signing a book maintained for such purpose" and such record shows the request made by McCoy after he was returned to the jail following his appearance in the police court. The bailiff and *76 clerk of the police court who were on duty at the time of McCoy's arraignment and sentence each deny that any defendant who requested counsel was told by an officer of the court "that he would have to answer guilty or not guilty to the charge or that he could see a lawyer when he got out."
 [1] From these affidavits, it reasonably may be concluded that, prior to his arraignment and plea of guilty, the petitioner made several requests for counsel which were refused by the officers who had him in custody. By Penal Code, section 686, the California Constitution (art. I,  13), and in accordance with the due process clause of the Fourteenth Amendment of the United States Constitution, a defendant in a criminal action is entitled to counsel (House v. Mayo, 324 U.S. 42, 46 [65 S.Ct. 517, 89 L.Ed. 739], Glasser v. United States, 315 U.S. 60 [62 S.Ct. 457, 86 L.Ed. 680]; Johnson v. Zerbst, 304 U.S. 458 [58 S.Ct. 1019, 82 L.Ed. 1461]; People v. Lanigan, 22 Cal.2d 569 [140 P.2d 24, 148 A.L.R. 176]; People v. McGarvy, 61 Cal.App.2d 557 [142 P.2d 92]). [2] The conduct of an officer of a state court constitutes state action within the meaning of the due process clause, even where the act violates a special command of state law such as the requirement of the Penal Code (Iowa-Des Moines National Bank v. Bennett, 284 U.S. 239 [52 S.Ct. 133, 76 L.Ed. 265]); therefore, the refusal to grant petitioner's request for counsel clearly constituted a denial of fundamental civil rights.
 [3] A writ of habeas corpus may not be used as a substitute for an appeal (In re Byrnes, 26 Cal.2d 824, 827 [161 P.2d 376]; In re Bell, 19 Cal.2d 488, 492 [122 P.2d 22]), but a "violation of the defendant's constitutional rights during the trial leading to his conviction is ground for attack on the judgment in a habeas corpus proceeding if the petitioner has no other adequate remedy to test the constitutionality of the proceeding resulting in his conviction." (In re Wallace, 24 Cal.2d 933, 938 [152 P.2d 1].) In the present case, the time for appeal had expired before the petitioner was able to obtain legal aid and the record upon an appeal would not show the violation of his right to counsel.
 [4] The State contends that if this court determines that McCoy should be discharged from custody of the Sheriff of Alameda County "he should be sent back to the Police Court, be permitted to withdraw his plea, given the right to engage counsel and proceed with his defense." This presents the question as to whether or not a petitioner who is wrongfully *77 imprisoned may be remanded to the trial court for correction of procedural errors.
 Section 1484 of the Penal Code provides that in a proceedings on habeas corpus "... The court or judge must ... dispose of such party as the justice of the case may require ..." So a petitioner will not necessarily be discharged merely because the judgment and commitment are void, if there is valid process under which he may be held. (In re Dal Porte, 198 Cal. 216 [244 P. 355]; Matter of Smith, 152 Cal. 566 [93 P. 191]; and see In re Mize, 11 Cal.2d 22 [77 P.2d 472]; 13 Cal.Jur. 281.) The petition of McCoy shows that he was arrested upon the charge of the commission of a misdemeanor. Subsequent action of the court officers, depriving the trial court of jurisdiction to convict and sentence McCoy, did not acquit him of the offense, and he is still subject to be tried upon any valid charge made against him in the complaint.
 In the case of In re Bouchard, 38 Cal.App. 441 [176 P. 692], the court did not hold the judgment and sentence to be void, but the petitioner was discharged because he had already served over 12 months, and "the 'justice of the case' does not require that the prisoner be remanded." (P. 444.) However, in both Matter of Smith, supra, and In re Del Porte, supra, although the court held that the judgments of conviction were void and the imprisonments illegal, the prisoners were remanded to the custody of the sheriff to await further action of the trial court.
 No reason appears for treating a case where the defendant is deprived of his right to counsel differently from one in which other procedural error or irregularity has occurred. Accordingly, the writ is discharged and the petitioner is remanded to the custody of the sheriff for further proceedings in the police court of the city of Oakland, in conformity with his constitutional right to counsel.
 Gibson, C.J., Shenk, J., Carter, J., Traynor, J., Schauer, J., and Spence, J., concurred.
