A writ that is usually used to bring a prisoner before the court to determine the legality of his imprisonment. It may also be used to bring a person in custody before the court to give testimony, or to be prosecuted.