
691 P.2d 449 (1984)
SHERIFF, CLARK COUNTY, Nevada, Appellant,
v.
William L. HATCH, Respondent.
SHERIFF, WASHOE COUNTY, Nevada, Appellant,
v.
Sharon K. ANDERSON, Respondent.
Nos. 15655, 15957.
Supreme Court of Nevada.
December 6, 1984.
*450 Brian McKay, Atty. Gen., Carson City, Robert Miller, Dist. Atty., Clark County, Las Vegas, for appellant Clark County Sheriff.
Foley and Foley, Las Vegas, for respondent Hatch.
D. Brian McKay, Atty. Gen., Carson City, Mills Lane, Dist. Atty., Washoe County, Reno, for appellant Washoe County Sheriff.
David G. Parraguirre, Public Defender, Washoe County, Reno, for respondent Anderson.

OPINION
SPRINGER, Justice:
These two appeals are from orders granting writs of habeas corpus releasing respondents Hatch and Anderson from custody and dismissing criminal prosecutions against them. Writs were granted on the ground that the justice's courts had "erred" in granting discretionary continuance of a preliminary examination (Hatch) and of a misdemeanor trial (Anderson). The writs will be quashed.


Impropriety of Habeas Corpus To Review "Error" of Justice's Court In Granting Continuances

It is fundamental that there are two different ways in which judicial action can be avoided or defeated. One is by direct attack, which is a complaint to a superior court that error has been committed by an inferior one, whose judgment or decision the court above is called upon to correct or reverse. The process is ordinarily called "appeal."
An indirect or collateral attack, on the other hand, is an attempt to avoid or defeat a judicial decision or judgment in an independent proceeding  a proceeding which has a purpose other than that of impeaching or overturning the decision or judgment.
Habeas corpus is a form of collateral attack  an independent proceeding instituted for the purpose of testing the legality of detention. It is a separate action to determine whether a defendant is being unlawfully deprived of his or her liberty and is not an appropriate proceeding for appeal-like review of discretionary decisions of a lower court.
In the two cases before us, however, the district courts were clearly employing the collateral writ process to correct perceived error on the part of justice's courts in their making of discretionary decisions. This court expressly disapproved of this process in Sheriff v. Sepulveda and Johnson, 99 Nev. 827, 673 P.2d 137 (1983), wherein it was held that the "district court does not have jurisdiction to review collaterally rulings of a magistrate at the preliminary stage of a prosecution." For reasons analogous to those stated in Sepulveda, the district court is also without the power to review, on habeas corpus, the discretionary decision of a justice court in granting a continuance of a misdemeanor trial.
Habeas corpus properly lies only to test the legality of detention. In these two cases the courts made no finding of illegal detention nor is there any discernible basis for such a finding. Rather, it appears that the district courts were not considering unlawful detention but were acting as though they were courts of appeal on direct review of an inferior tribunal.
In each case the district court found that its inferior court had "erred" in granting a continuance. Hatch involves a continuance of a preliminary examination, and Anderson involves a continuance of a misdemeanor trial. The principle in both cases, however, is the same: habeas corpus cannot be employed as an appeal or writ of error. The correct procedure for reviewing such discretionary decisions is by direct attack, by appeal, not by habeas corpus.[1]*451 The district courts in these two actions improperly granted the writs of habeas corpus; and, accordingly, the writs will be quashed.

"Conscious Indifference and Willful Failure of Prosecution"
In both of these cases the district courts advert to prosecutorial dereliction in the form of "conscious indifference" to rules of procedure affecting a defendant's right or in the form of willful failure to comply with such rules. These concepts have no application to the cases now before us. Such prosecutorial conduct is considered only in cases in which an action against a defendant has been properly dismissed at the preliminary examination stage, and the state subsequently reinstates prosecution of the case. For example, in Maes v. Sheriff, 86 Nev. 317, 468 P.2d 332 (1970), the state failed to observe the procedural requirements in seeking a continuance of a preliminary examination, and the complaint was dismissed by the magistrate. The state subsequently filed an identical complaint charging the same offense. This court issued a writ of habeas corpus, holding that a new criminal proceeding was not allowable when the original proceeding had been dismissed due to willful failure of the prosecution to comply with required procedural preconditions.
We made a related ruling in State v. Austin, 87 Nev. 81, 482 P.2d 284 (1971). There we upheld the district court's dismissal of a second accusation on the ground that the accused had been denied the constitutional right to a speedy trial in a case in which there had been a "conscious indifference" to rules of procedure affecting an accused's rights.
Since questions relating to the institution of a second criminal charge do not arise in either of the cases now before us, matters of willful failure or conscious indifference relative to procedural rights of an accused are irrelevant here. Such matters were not, therefore, the proper subject of consideration by the district courts.
For the reasons stated, the writs of habeas corpus were improperly granted; the writs are therefore quashed with instructions that the prosecutions may proceed in due course.
MANOUKIAN, C.J., and MOWBRAY, STEFFEN and GUNDERSON, JJ., concur.
NOTES
[1]  This is not to say that habeas corpus will never be an appropriate proceeding in a district court. We note again, as we did in Sepulveda's companion case, Sheriff v. Blackmore, 99 Nev. 827, 673 P.2d 137 (1983), that where an accused is detained unlawfully by reason of violation of jurisdictional procedural requirements, denial of speedy trial, or other proper grounds, a district court may review the legality of the detention on habeas corpus.
