Under Virginia law, habeas corpus is a civil proceeding used to challenge and remedy due process violations. A petition for writ of habeas corpus is a legal action that allows individuals to challenge their unlawful imprisonment or restraint.It tests the legality of a detention or a restraint and the goal is to use it really almost i guess it's an emergency basis. A habeas corpus petition attacking a criminal conviction or sentence shall be filed within two years from the date of final judgment in the trial court. A writ of habeas corpus is used to bring a prisoner or other detainee (e.g. The writ of habeas corpus, also known as the Great Writ, is a U.S. legal process that determines whether an offender's imprisonment is valid. The Writ of Habeas Corpus protects prison inmates from false imprisonment to ensure people are not thrown into jail unlawfully.