When a prisoner confined in jail, or who is in legal custody, shall die, the officer having charge of the prisoner shall forthwith report the same to a justice of the peace of the county, who shall hold an inquest to ascertain the cause of the prisoner's death. All the proceedings had in such cases shall be reduced to writing, certified and returned as in other cases of inquest; a certified copy of which shall be sufficient proof of the death of the prisoner at the hearing of an application for a writ of habeas corpus.
Tex. Code Crim. Proc. § 11.38