When it appears from the return that the party is imprisoned or restrained on a criminal accusation, the court or judge shall make no order for the discharge of the party until notice of the return is given to the district attorney of the county where the party is imprisoned or restrained.