Section 29. A prisoner held in jail for trial upon an indictment for an offence not punishable by death or by imprisonment for life, or so held upon an appeal, at any time except during a sitting of the superior court for criminal business in the county where he is held, may petition said court that he be brought before the court at a sitting thereof for civil business in that county in order that disposition may be made of his case. After due notice to the district attorney, and with his consent, the court may grant the petition, and the presiding justice may dispose of the case, as if he were holding a sitting of the court for criminal business, or he may continue the case to the next sitting of the court for criminal business. When a person who has a right to so petition is committed to jail, the keeper thereof shall notify him of such right, furnish him with a blank form for its exercise, and transmit it to the court, if signed by him. This section shall not apply in cases in which two or more persons are held on one complaint or indictment, unless all the defendants join in the petition.