Whenever any court of record, or any judge thereof, shall have evidence, from any judicial proceedings had before such court or judge, that any person is illegally confined or restrained of his liberty, within the jurisdiction of such court or judge, it shall be the duty of the court or judge to issue a writ of habeas corpus for his relief, although no application or petition be presented for such writ.
§ 532.070, RSMo