McKinstry, J.
The judgment in favor of plaintiff in the ejectment suit—Walsh v. Hill et al.—was entered February 25, 1873. The present action is on an undertaking, given on appeal from that judgment, to stay its execution. Amongst other things, the undertaking provides, that “if the judgment appealed from be affirmed, or the appeal be dismissed, they ” (present defendants) “ will pay the value of the use and occupation of the property, from the time of the appeal until the delivery of the possession thereof,” etc. The answer herein avers that long before the entry or rendition of the judgment in ejectment, the plaintiff therein—plaintiff herein—had conveyed all his right, title and interest in the premises demanded to Mason and Bensley. The court found that such conveyance was made after the commencement of, and before the rendition of, judgment in the action Walsh v. Hill et al.
The statutory undertaking is provided for as part of the procedure relating to appeals, and in each case has reference to a particular judgment and its execution. (C. C. P., § 945.) It is made primarily for the benefit of the plaintiff in the judgment to which it refers, and should be treated as if in terms made to him. It is executed to indemnify the plaintiff against damages *445sustained by the wrongful withholding of the possession of the demanded premises by the defendant in the judgment, pending an appeal, and until the plaintiff shall regain possession. As between the plaintiff and defendant, in the action of ejectment, the judgment in that action conclusively determines that it is the plaintiff from whom the defendant has wrongfully withheld the possession. And the judgment is evidence (at least prima facie) that the plaintiff is the person from whom the defendants continued to withhold the possession pending the appeal, and until, etc. The grantee of a plaintiff in ejectment, pendente lile, acquires no right which can be enforced in the action, or under the judgment, in his own name, unless he shall have had himself substituted as plaintiff. (C. C. P., § 385.) The rights he acquires—so far as they depend upon the action of ejectment, the judgment therein, or its execution—remain to be enforced for his benefit in the name of the plaintiff. If the grantee is substituted, under section 385, he himself becomes the plaintiff. If he is not so substituted, he does not, as grantee of plaintiff’s estate in the land, become the legal assignee of plaintiff, as to an undertaking executed on appeal from a judgment subsequently entered in favor of plaintiff. By omitting to apply to be substituted as plaintiff, he makes the nominal plaintiff his trustee, to prosecute the action and recover the possession in his own name. The grantee of plaintiff cannot apply in his own name for a writ of restitution, or to be placed in possession under a judgment in favor of his grantor, unless he has been substituted as plaintiff. The judgment, in ejectment has adjudged the plaintiff therein to be entitled to the possession of the demanded premises, and the claim here sought to be enforced is based on a contract which relates to that judgment, and to the delivery of the possession to the party in whose favor the judgment was rendered. There is no pretense of an assignment of the undértaking after it was made.
With certain exceptions, every action must be prosecuted in the name of the real party in interest. (C. C. P., § 367.) But here the undertaking was in legal effect given to the party plaintiff in the ejectment, to whom, as the court below finds, was delivered the possession of the demanded premises. If the grantees of the plaintiff, of a date prior to the judgment, ac*446quired any interest in the value of the use and occupation of the defendant in the ejectment, it was one to be enforced against or in the name of their grantor. As to the undertaking, it is to pay plaintiff the value of the use and occupation. In legal effect the contract is made with him, and if others have claims on him with respect to it, he should be held as to them to be a trustee of an express trust, authorized to sue on the undertaking. (C. C. P., § 369.)
Judgment affirmed.
Ross, J., and McKee, J., concurred.
Hearing in Bank denied.