
132 N.W.2d 811 (1965)
STATE of Minnesota, Respondent,
v.
Richard J. CLARK, Relator.
No. 39652.
Supreme Court of Minnesota.
January 22, 1965.
Cochrane, Thomson & Bresnahan, and Edward J. Drury, St. Paul, for relator.
Walter F. Mondale, Atty. Gen., Charles E. Houston, Asst. Atty. Gen., St. Paul, Robert W. Johnson, County Atty., Gabriel Giancola, Asst. County Atty., Anoka, for respondent.
*812 MURPHY, Justice.
This is an original proceeding upon defendant's petition for a writ of habeas corpus. He is at liberty on bond fixed by a committing magistrate for his appearance in the district court. He contends that the appearance bond has placed him under illegal restraint and seeks to test the asserted illegality by the writ of habeas corpus.
From an examination of the record it appears that defendant was charged by criminal complaint in the municipal court of Fridley, Anoka County, with violation of Minn.St. 609.52, subd. 2(6), (L.1963, c. 753) which denounces the offense of the person who finds lost property and "knowing or having reasonable means of ascertaining the true owner, appropriates it to his own use * * * without first having made reasonable effort to find the owner and offer and surrender the property to him." After a preliminary hearing the magistrate found that there was probable cause to believe him guilty of the crime charged. The bond for appearance at the opening of the next general term of the district court was fixed in the amount of $1,000.
There is some reference in the petition to the claim that the evidence at the preliminary hearing was not sufficient to hold defendant for arraignment in the district court. We have examined the transcript of the evidence taken before the magistrate. It is unnecessary to review the facts established by the prosecution at the preliminary hearing. It is sufficient only to say that there was ample evidence to warrant the determination of the magistrate that there was probable cause to believe defendant guilty of the crime charged. We gather from the oral argument and brief of defendant's counsel that he does not seriously contend otherwise. The principal burden of his claim is that defendant is restrained of his liberty by reason of the bond for appearance in the district court. He argues:
"* * * there are real and limiting restraints on petitioner's liberty. He must not only appear as ordered from time to time as ordered by the Municipal and District Courts he is subject to the whim of the County Attorney as to when he must appear. * * *
"It is respectfully submitted that one on bail is not at liberty and hence may challenge the restraints placed upon his liberty by use of the Great Writ."
Defendant relies on Jones v. Cunningham, 371 U.S. 236, 83 S.Ct. 373, 9 L.Ed.2d 285, 92 A.L.R.2d 675, and In re Petersen, 51 Cal.2d 177, 331 P.2d 24, 77 A.L.R.2d 1291. We do not think the Jones case has valid application here. In that case it was held that habeas corpus was available to a state prisoner on parole to bring up for review the validity of a sentence imposed, which petitioner claimed was invalid because his Federal constitutional right to counsel had been denied him at the trial. This holding is in accord with numerous decisions of both this court and the Supreme Court of the United States to the effect that habeas corpus may be used as a postconviction procedure to inquire into alleged violations of freedoms considered to be basic and fundamental.
In State ex rel. Bassett v. Tahash, 263 Minn. 447, 448, 116 N.W.2d 564, 565, we said:
"* * * Essentially the function of the writ of habeas corpus is to relieve one from unlawful restraint. In reviewing a denial of the writ our concern is primarily directed to the question of whether the committing court had jurisdiction of the crime and of the person of the defendant; whether the sentence was authorized by law; and whether the defendant was denied fundamental constitutional rights."
See, State ex rel. Cole v. Tahash, 269 Minn. 1, 5, 129 N.W.2d 903, 906; State ex rel. Naus v. Rigg, 250 Minn. 365, 367, 84 N.W.2d 698, 700; Fay v. Noia, 372 U.S. 391, 83 S.Ct. 822, 9 L.Ed.2d 837; Sanders v. United States, 373 U.S. 1, 83 S.Ct. 1068, 10 L.Ed.2d 148; Townsend v. Sain, 372 *813 U.S. 293, 83 S.Ct. 745, 9 L.Ed.2d 770; Gideon v. Wainwright, 372 U.S. 335, 83 S.Ct. 792, 9 L.Ed.2d 799.
Nor do we think that In re Petersen, supra, has significant application. In that case, which involved a prosecution for violation of a municipal taxicab ordinance, it was held that habeas corpus was an appropriate remedy to test the constitutionality of the ordinance, even though bail had been allowed.
As we understand the argument of counsel for defendant as expressed orally and by his brief, it is that the writ of habeas corpus entitles him to relief because of the asserted fact that the bond for his appearance places him under constructive restraint. This claim is met by our decision in State ex rel. McMonagle v. Konshak, 136 Minn. 331, 332, 162 N.W. 353, in which we said:
"* * * A person who is at liberty on bail is not imprisoned or restrained and is not entitled to the writ."
It may further be observed that if it is conceded that the bail bond places defendant under a constructive restraint, there is nothing to indicate that such restraint is unlawful. Relief by habeas corpus may be had under the provisions of Minn.St. 589.01 only where "such imprisonment or restraint * * * proves to be unlawful." State ex rel. Bassett v. Tahash, supra. The legality of the restraint or detention at the time of the writ defeats the relief sought by it. There is no serious claim made by defendant that an illegal restraint arises from lack of jurisdiction; that the complaint does not state a public offense under a valid statute; or that he has been denied bail or that the bail fixed by the magistrate is excessive in violation of his constitutional rights (U.S. Const. Amend. VIII and Minn.Const. art. 1, §§ 5 and 7). Nor is it asserted that there has been undue delay in prosecution or that there has been a denial of any conceivable basic or fundamental right. The bail was fixed by the magistrate pursuant to his statutory authority.[1]
Defendant's argument ignores the reason and importance of bail. The right to release before trial is conditioned upon the accused giving adequate assurance that he will stand trial and submit to sentence if found guilty. The function of bail is described by Chief Judge Gardner in United States ex rel. Heikkinen v. Gordon (8 Cir.) 190 F.2d 16, 19, as follows:
"* * * The rules and rights of the parties in criminal and civil bail are similar in many respects. The accused or principal in either case is released from custody of the law and placed in the custody of keepers of his own selection, and it is said that the object of bail is to relieve the accused of imprisonment and the state of the burden *814 of keeping him pending trial or hearing and at the same time to secure the appearance of the accused at the trial or hearing."
Moreover, it should be noted that the respondent named in this proceeding is the county attorney who is alleged to have custody of defendant. It appears from Jones v. Cunningham, supra, that habeas corpus will not lie if the person seeking the writ is not in actual or constructive custody of the official or authority to whom the writ is directed. As Judge Gardner pointed out in the Gordon case (190 F.2d 19) the bail bond places a defendant "in the custody of keepers of his own selection." We are of the view that the county attorney is not a proper respondent with custody. De Paunto v. People (6 Cir.) 332 F.2d 396; United States v. Dumeur (S.D.N.Y.) 214 F.Supp. 293; Bowen v. Harris (W.D.Mo.) 224 F. Supp. 976. We must accordingly conclude that the petition not only lacks substance, but that the procedure by writ of habeas corpus is not appropriate.
Writ quashed.
NOTES
[1]  Minn.St. 629.53 provides: "When at the close of an examination it shall appear that an offense has been committed, and that there is probable cause to believe the prisoner to be guilty, if the offense be bailable by the magistrate, and the prisoner shall offer sufficient bail or money in lieu thereof, it shall be taken, and he shall be discharged; but if no sufficient bail be offered, or the offense shall not be bailable by the magistrate, he shall be committed for trial. When cash bail shall be deposited in lieu of other bail, such cash shall be the property of the accused, whether deposited by him personally or by any third person in his behalf. When cash bail shall be accepted by a judge of a court of record, he shall order the same to be deposited with the clerk, there to remain until the final disposition of the case and the further order of the court relative thereto. Upon release, in whole or in part, the amount so released shall be paid to the accused personally or upon his written order. In case of conviction the magistrate may order such deposit to be applied upon any fine imposed and, if such fine be less than the deposit, the balance shall be paid to the defendant. If the fine exceeds the deposit, the deposit shall be applied thereon and the defendant committed until the balance is paid, but such commitment shall not exceed one day's time for each dollar of such unpaid balance. Cash bail in the hands of the court or any officer thereof shall be exempt from garnishment or levy under attachment or execution."
