If it appears from the return of the writ or otherwise that the prisoner is imprisoned on a criminal accusation, he shall not be discharged until notice has been given to the attorney general or other attorney for the commonwealth.
Mass. Gen. Laws ch. 248, § 17