Section 40. Upon the return of the notice, and upon proof of service of all orders of notice issued, the court may appoint a disinterested person to act as guardian ad litem for minors, and for persons under disability, and for all persons not in being, unascertained, unknown or out of the commonwealth, who may have an interest. The compensation of the guardian shall be determined by the court and paid as it may direct.