When the appellate division or superior court division, or any judge of either division, has evidence from any judicial proceeding before such court or judge that any person within this State is illegally imprisoned or restrained of his liberty, it is the duty of said court or judge to issue a writ of habeas corpus for his relief, although no application be made for such writ.
N.C. Gen. Stat. § 17-8