The Court or Judge, if the time during which such party may be legally detained in custody has not expired, must remand such party, if it appears that he is detained in custody:
1.By virtue of process issued by any Court or Judge of the United States, in a case where such Court or Judge has exclusive jurisdiction; or,
2.By virtue of the final judgment or decree of any competent Court of criminal jurisdiction, or of any process issued upon such judgment or decree.