In this writ proceeding, the superior court was ordered to conduct immediate hearings as to whether two minors, who had been detained for ten weeks as material witnesses in a special circumstance murder prosecution, should continue to be detained. Under Penal Code section 1332, the trial court may detain a material witness to a prosecution where there is good cause to believe that he will not attend the trial and testify, but discretion to detain is not unfettered. Section 1332 is not unconstitutional on its face because it can be applied fairly with adequate procedural safeguards. The statute clearly contemplates a hearing in which the witness should have counsel, and factors that can be taken into consideration, including the nature of the testimony, the age of the witness, the harm to the witness flowing from incarceration, and whether appearance can be assured without incarceration. Here, although immediate release was denied, the matter had to be remanded to consider those factors before continuing to detain the minors.