A writ of habeas corpus is a legal petition filed with a court that essentially demands the government justify why a person is being held in custody. The Latin phrase translates to "you shall have the body," which in practice means the government must bring the person before the court and provide a valid legal reason for the detention. If the court finds the imprisonment is unconstitutional or unlawful, it can order the person released.
In the context of a prison sentence, a habeas petition is not a challenge to whether the person committed the crime. It is a challenge to determine whether the manner of imprisonment or the legal process that produced the conviction violates constitutional rights. Common grounds include ineffective assistance of counsel, violations of due process, new evidence that was not available at trial, or conditions of confinement that constitute cruel and unusual punishment.
When a habeas petition is granted, it does not automatically mean release. It means the court has agreed to take another look, giving the petitioner what amounts to another day in court to present their constitutional argument. Release only follows if the court ultimately rules in the petitioner's favor on the merits.
On filing multiple petitions: courts generally allow only one federal habeas petition per conviction under most circumstances. Subsequent petitions are heavily restricted under the Antiterrorism and Effective Death Penalty Act and require specific conditions to be filed again. On the question of using a habeas writ to address pending charges from the Department of Corrections, that is a more specific and technical question that requires an attorney to evaluate based on the exact circumstances.