The petitioner, Malcolm G. Sutherland, invokes the original jurisdiction of this court through the writ of habeas corpus, Code, 51-1-3, and seeks relief from imprisonment imposed upon him by a special judge, sitting in the circuit court of Logan County, in the divorce proceeding of Anna Sutherland against Malcolm G. Sutherland, in which the petitioner was adjudged in contempt of court on account of failure to pay alimony and suit money decreed to be paid by him to Anna Sutherland, and committed to jail, there to be held until the order of the court with respect thereto should be complied with.
A short summary of the events leading up to the filing of the petition in this proceeding seems necessary. On September 10, 1935, a decree was entered in favor of Anna Sutherland in the original cause, granting to her a divorce with alimony, and provided for the custody of the children of the marriage thereby dissolved. The alimony was paid for a time, but on January 25, 1937, complaint was made on account of failure to pay, and orders were entered respecting such complaint on March 8, 1937, March 19, 1937, and March 23, 1937. By the order of March 23,1937, it appears that some question had arisen as to whether or not the special judge had been duly elected as such, and it was then agreed, and made a matter of record, that such special judge had been legally elected, and that the orders theretofore made by him in said cause were valid and binding. On April 12, 1937, an order was entered in the cause, showing the election of the special judge and an agreement between the parties and their counsel that he should continue to have jurisdiction of the cause. Thereafter, on July 30, 1937, an order was entered by the special judge with respect to alimony. On November 8, 1937, a petition for abatement or reduction of the alimony was filed by petitioner, a hearing had, and alimony fixed at $65.00 per month, so long as a son of the petitioner should be kept in college, and to be increased to $100.00 per month should the son be taken out of college. From this decree, an appeal was allowed by this court on November 23, 1937, and is now *685on the docket for future hearing.
On January 28, 1938, the matter of alimony pending in the appeal, and the allowance of money for counsel fees therein, was considered by the special judge. On that date, for the first time, the question of the right of the special judge to act in the cause was raised by the petitioner. The objection then raised to the jurisdiction of the special judge was overruled, and, notwithstanding the fact that an appeal had been awarded by this court to the order of November 10, 1937, awarding alimony at the rate of $65.00 per month, the special judge allowed the same amount as temporary alimony pending such appeal, and in addition thereto, $100.00 for counsel fees. The petitioner, not paying the alimony and counsel fees so directed to be paid, was, on February 14, 1938, upon a hearing held before said special judge, adjudged to be in contempt of court and committed to jail until he should pay the sum of $165.00 and continue to pay $65.00 each month until the further order of the court. Thereupon, petitioner invoked the original jurisdiction of this court through the writ of habeas corpus.
Petitioner asserts two grounds on which he alleges he should be released from custody: (1) that the special judge was not legally elected and had no jurisdiction to enter the order allowing alimony and counsel fees, and that such order, being void, could not be made the basis of a contempt proceeding; and (2) that the petitioner had purged himself of the contempt alleged by reason of a clear showing that he was unable to comply with the order of the court with respect to the payment of alimony and counsel fees. These positions will be taken up in their order.
Section 10, Article 2, Chapter 51 of the Code provides for the election of a special judge in the absence of a regular judge or where it is improper for him to act, and provides that when such special judge is to be elected for a particular case, no election shall be held until an order shall be entered by the regular judge naming the case and stating the reasons which make it necessary to elect such special judge; also, that at least one attorney of *686record for each of the parties to such suit shall have reasonable notice in writing of the time of any proposed election, which notice, and the return of the service thereof, shall be filed and made a part of the record in the case. There is also a provision by which by agreement in writing, counsel for parties may select a judge for the trial of any case, and that such agreement shall be entered upon the record of the court. The petitioner herein contends that the statute was not complied with in this election of the special judge who entered the orders complained of in the divorce proceeding aforesaid.
On behalf of the respondent, it is contended that the order of April 12, 1937, above referred to, confers jurisdiction on said special judge. This order was entered by the regular judge of the Circuit Court of Logan County, and shows his disqualification to hear the cause on account'of his former connection therewith as an attorney for one of the parties, and it was then ordered that an election be held by the members of the bar for the purpose of selecting a special judge to hear and determine the matters in controversy between the parties to the cause. No notice seems to have been given of such election, as required by law. The order then shows that the clerk held an election, resulting in the selection of the special judge whose orders are complained of, and the oaths required by statute were administered to him. The order also states that “it was further agreed by the parties to this suit and by their counsel, that the said J. E. Peck shall continue to have jurisdiction of this cause for the purpose of hearing and determining any and all questions hereafter arising in this cause until the further order of the court.” •
We hold that the statute was complied with in respect to the requirement that an order be entered reciting the cause for the election of a special judge. It was, of course, not complied with in respect of the requirement that notice in writing be given to at least one counsel for each of the parties. But, the very purpose of notice was to bring the parties into court, and the order shows that they were not only present at the date of this elec*687tion, but that at the same time, after the election and after the oaths had been administered, they agreed that the special judge so elected should have jurisdiction of the cause. It is true that the statute requires 'written notice of an election and, in case of an agreement upon a special judge, a writing to be entered upon the records of the court, but an appearance in a court of record by parties to litigation and agreements entered into with respect to any matter which may be effectuated by a decree or order, and which are made a matter of record have always been held to be equal in force and effect to a written agreement. We are not unmindful of the holdings of this court in State v. Cross, 44 W. Va. 315, 29 S. E. 527; State v. Amos, 100 W. Va. 555, 131 S. E. 264; Brown v. Miller, 103 W. Va. 282, 137 S. E. 227. In the Cross case, the election was declared to be void because an order had not been entered, reciting the causes for which the election was to be held. In the Amos case,' a question of whether proper notice had been given was the deciding factor. In the Brown case, it was decided principally upon the ground that the record disclosed no order reciting the disqualification of the judge, nor did it show an agreement in writing signed by the parties or their counsel. Being of the opinion that a proper order was entered directing the election, and the parties and their counsel being present in court at the time of the election, and after, by agreement made a matter of record, conferring on the special judge so elected jurisdiction to hear the cause, and especially in view of the fact that without objection, the special judge so elected was later permitted to enter decrees and orders in the cause, under such agreement and election, the petitioner cannot now be heard to say that the special judge did not have jurisdiction to enter the judgment of contempt complained of. Jurisdiction of the subject matter of a cause cannot be conferred upon a court by consent, but where a court has jurisdiction of the subject matter (and as to that no question is raised in this cause), agreements may be made with respect to all matters necessarily arising in the progress of the cause. The right to agree upon a *688special judge is expressly conferred by statute, although, it is stipulated that that agreement shall be in writing and be entered upon the court’s record. Having the power to agree upon the selection of a special judge, litigants will not be permitted to make solemn agreement at one term of the court and later to repudiate that agreement when they become dissatisfied with the court’s decrees. Unfortunate as it may be, all litigants must take the risk of a court being wrong in any case submitted.
While we think the court had jurisdiction to enter the order complained of, we are of the opinion that he abused the discretion vested in him when, in view of the showing made on the hearing of the charges of contempt, he adjudged the petitioner to be in contempt of court and committed him to jail for failure to pay the full amount of the alimony decreed. The action of this court in the granting of an appeal from the order of November 10, 1937, awarding alimony at the rate of $65.00 per month, should have placed the special judge on notice that there was at least doubt as to the correctness of his order. In the face of this appeal, he awarded exactly the same sum as temporary alimony, thereby in effect nullifying this court’s order. The appeal granted served as a suspension of the former order, yet substantially the full force and effect thereof is restored by the order of January 28, 1938. Furthermore, the record clearly shows that the business of the petitioner is at the present time in a precarious state. There is good reason to believe that, under present conditions, he is unable to pay the amount of alimony fixed and maintain himself and his family. A showing of inability to perfrom the terms of a decree allowing alimony has always been considered as a purge of contempt, and the record shows that petitioner appeared before the special judge and testified as to his inability to meet the court’s order, notwithstanding which he was committed to jail, the effect of which will necessarily be to destroy whatever prospects he has of being able to pay any alimony whatever. We think it a case where the special judge was guilty of a grave abuse of discretion. Furthermore, it appears that the respondent, *689Anna Sutherland, has an income of $15.00 per week; that her daughter, who lives with her, has an income of $100.00 per month, and from this we are of opinion that neither the financial condition of the petitioner nor the needs of the respondent warrants the harsh sentence imposed by the special judge. Ex parte Beavers, 80 W. Va. 34, 91 S. E. 1076, is authority for the proposition that a party, in attempting to purge himself of contempt, should make an application for relief in the court by which he was committed, but the futility of any effort along that line before the acting special judge is quite apparent, and justifies the direct application to' this court for relief. We are of opinion to award the writ and release the petitioner from custody. However, in awarding the writ, we do not pass upon the right of the respondent to a proper allowance of alimony to be made in consideration of all the circumstances of the case and of the parties, and within the spirit of Section 15, Article 2, Chapter 48 of the Code, wherein consideration is required to be given to the circumstances and needs of the parties involved; nor is it meant to deprive the respondent of right to reasonable counsel fees in the appeal now pending in this court in the principal case. The allowance of the special judge for counsel fees is not condemned, and this decision rests' upon what we consider an abuse of discretion vested in the special judge with respect to the allowance of temporary alimony in the amount fixed, and especially the abuse of discretion involved in imposing imprisonment for contempt where the circumstances of the case suggested a different course.
Writ awarded.