TreeHouse Foods has reached an agreement to sell its snacks operations having put the business up for sale last year.