South Africa are well on top in the second Test against Bangladesh in Chittagong, with the hosts losing four wickets and facing a mammoth first-innings deficit.