40 (1) Where a judge is satisfied upon evidence under oath or affirmation, that a person is able to give material evidence that is necessary in a proceeding under this Act and, (a)  will not attend if a summons is served; or (b)  attempts to serve a summons have been made and have failed because the person is evading service, the judge may issue a warrant in the prescribed form for the arrest of the person. Idem (2) Where a person who has been served with a summons to attend to give evidence in a proceeding does not attend or remain in attendance, the court may, if it is established, (a)  that the summons has been served; and (b)  that the person is able to give material evidence that is necessary, issue or cause to be issued a warrant in the prescribed form for the arrest of the person. Bringing before justice (3) The police officer who arrests a person under a warrant issued under subsection (1) or (2) shall immediately take the person before a justice. Release on recognizance (4) Unless the justice is satisfied that it is necessary to detain a person in custody to ensure his or her attendance to give evidence, the justice shall order the person released upon condition that the person enter into a recognizance in such amount and with such sureties, if any, as are reasonably necessary to ensure his or her attendance. Bringing before judge (5) Where a person is not released under subsection (4), the justice of the peace shall cause the person to be brought before a judge within two days of the justice’s decision. Detention (6) Where the judge is satisfied that it is necessary to detain the person in custody to ensure his or her attendance to give evidence, the judge may order that the person be detained in custody to testify at the trial or to have his or her evidence taken by a commissioner under an order made under subsection (11). Release on recognizance (7) Where the judge does not make an order under subsection (6), he or she shall order that the person be released upon condition that the person enter into a recognizance in such amount and with such sureties, if any, as are reasonably necessary to ensure his or her attendance. Maximum imprisonment (8) A person who is ordered to be detained in custody under subsection (6) or is not released in fact under subsection (7) shall not be detained in custody for a period longer than ten days. Release when no longer required (9) A judge, or the justice presiding at a trial, may at any time order the release of a person in custody under this section where he or she is satisfied that the detention is no longer justified. Arrest on breach of recognizance (10) Where a person who is bound by a recognizance to attend to give evidence in any proceeding does not attend or remain in attendance, the court may issue a warrant in the prescribed form for the arrest of that person and, (a)  where the person is brought directly before the court, subsections (6) and (7) apply; and (b)  where the person is not brought directly before the court, subsections (3) to (7) apply. Commission evidence of witness in custody (11) A judge or the justice presiding at the trial may order that the evidence of a person held in custody under this section be taken by a commissioner under section 43, which applies thereto in the same manner as to a witness who is unable to attend by reason of illness.  R.S.O. 1990, c. P.33, s. 40.