Sri Lanka 110 and 130 for 4 (Mathews 29*, Chandimal 28*) require a further 377 runs to beat South Africa 392 and 224 for 7 dec (Elgar 55, Lakmal 4-69)
Live scorecard and ball-by-ball details

#PE: Should Herath be SL's batting coach?
#PE: Should Herath be SL's batting coach?

South Africa made inevitable progress towards the victory in Cape Town that would bring them a Test series win against a Sri Lanka side whose batting naivety has become more apparent as the series progresses. Four down at stumps, with their victory target merely a dot on the horizon, Sri Lanka can be expected to lose heavily on the fourth day and go to Johannesburg 2-0 down with one to play.

As Sri Lanka's batsmen floundered for a second time, there was reason to conclude that South Africa's first-innings lead of 282 would have been ample for an innings win. As it was, they had eschewed the follow-on on the previous day and instead the declaration came at 224 for 7, 75 minutes into the afternoon session.

A lead of 506 was impregnable. Well, not quite impregnable. There was always the slight possibility that a Russian cyberattack could send cricket scoring systems across the world haywire and Sri Lanka could emerge, somewhat sheepishly, with a win with two sessions to spare. The reality was somewhat more prosaic: 130 for 4 by the close of the third day, with the captain Angelo Mathews and his deputy Dinesh Chandimal hoping to save face on the morrow.

While South Africa's bowlers picked off Sri Lanka a second time, Board representatives were arranging a meeting with Kyle Abbott's agent, hoping to arrest his planned international retirement to join Hampshire, thereby making it one of the few occasions when it could be fairly observed that the administrators had a tougher job than the players. As for Abbott, the fates have playfully decreed (so far at least) that he remains wicketless.

There was a recognisable quality to Sri Lanka's dismissals, their limitations skilfully exposed, which emphasised South Africa's authority all the more. An inexperienced top order must learn the hard way while seasoned batsmen such as Chandimal and Upul Tharanga plug gaps lower down. The demands are high, perhaps unfairly so for some.

Dimuth Karunaratne had departed by tea, shrewdly set up by Vernon Philander before an inswinger drew an airy drive and rattled into his stumps through bat and pad.

Kusal Mendis is just as likely to end up as Sri Lanka's wicketkeeper-batsman as a Test No. 3 (although Kumar Sangakkara managed both). He replaced Kusal Perera at first-wicket down here, but he has batted skittishly and failed twice. After a top-edged sweep against the left-arm spin of Keshav Maharaj in the first innings, he succumbed to a catch at third slip as he drove on the up in Philander's fifth over. On this pitch, so early in the innings, it was a liberty.

Kaushal Silva has a stubborn streak, but the short ball looks capable of unsettling him and when Kagiso Rabada upped his pace in his second spell, a venomous rising delivery was fended to short leg. Dhananjaya de Silva is only in his seventh Test, so could be forgiven perhaps for walking off for a debatable lbw decision in Rabada's next over, but had his captain, Mathews, at the non-striker's end, thought to suggest a review, the ball would have been shown to be sailing past leg stump.

It was not all delight for South Africa. Hashim Amla would have liked to have walked out to bat for his 100th Test at the Wanderers next week with his reputation reasserted. Instead he will take guard with continued chatter about his form after a duck before lunch.

Amla's sequence without a half-century now stretches to 10 innings, his latest failure coming with a fifth-ball nought in an otherwise dreary phase of the Test of little consequence in which South Africa, resuming with a lead of 317 and all wickets remaining, engaged in some cricketing arithmetic for more than three hours as they totted enough runs for a fail-safe declaration. And then some.

Presumably Amla might now join those malcontents who thought, with good reason, that South Africa should have enforced the follow-on and sought to wrap the game up in three days. After all, only three sides have ever lost a Test after putting the opposition back in and, having dismissed Sri Lanka in 43 overs, South Africa's bowlers were hardly in need of recuperation.

At least it would have spared Amla that sinking feeling when he pushed routinely forward to an excellent delivery, seaming away around off stump, from Suranga Lakmal and felt the nick that was heading inexorably to the wicketkeeper

As ducks go, it was a highly respectable one. But it was still a duck. It will not quieten the discussions about how Amla tends to get caught on the crease, his graceful footwork no longer quite decisive enough. Only big runs will do that, and everybody presumes they will come. The only time he has had a sequence of failures as long as this was a year ago - and then he shot back with a double hundred against England in Cape Town. Jo'burg, on a historic personal achievement, might relight his fire.

Lakmal has had a good series and he matched the admirable standards that had brought him five wickets in Port Elizabeth, finishing with 4 for 69. He brightened Sri Lanka's morning with a double-wicket maiden. Five balls before he dismissed Amla, he accounted for Stephen Cook, a regulation slip catch for Karunaratne. JP Duminy and Faf du Plessis followed. Nuwan Pradeep reappeared after his thigh strain but was out of luck.

Dean Elgar, in trim after his first-innings hundred, seemed suited to such a morning. A measured tread with little pressure to talk of was right up his alley and another half-century was bagged. But the appearance of Rangana Herath's left-arm slows drew from Elgar an unexpected friskiness. He advanced down the pitch to a guileful third delivery which beat him in the flight. If he had not been caught at slip, he would have been stumped. Even on the most inconsequential mornings, satisfaction can be found and Herath, who looks capable of coping contentedly with mornings when nothing much happens, had drawn as much pleasure from it as anyone.

David Hopps is a general editor at ESPNcricinfo @davidkhopps