Whenever any court or judge, authorized to grant this writ, has evidence, from a judicial proceeding, that any person within the jurisdiction of such court or officer is illegally imprisoned or restrained of liberty, it is the duty of such court or judge to issue, or cause to be issued, the writ as aforementioned, although no application be made therefor.