Faf du Plessis was batting on 17 with skipper Hashim Amla on two.
South Africa lead the two-Test series 1-0 after winning the opener in Galle by 153 runs.