Real-time control of deuterium or helium gas injection by feedback on Langmuirprobe signals is implemented in Tore Supra ergodic divertor discharges. Thefeedback schemes are based on the robust experimental observation that thedensity limit coincides with the edge temperature Te~10 eV. Threecontrol algorithms are used: (1) proportional feedback on the centralline-averaged density with real-time attenuation of the system gain andsecurity cut-off of the gas injection if the edge temperature becomes too low;(2) proportional feedback on the central line-averaged density with securitycut-off controlled by the degree of detachment (DoD); (3) proportionalfeedback on edge temperature with security cut-off on the DoD. The DoD is defined for deuterium discharges, but not for helium sincethose do not detach. All three feedback modes permit operation close to thedensity limit and have been successfully applied for plasma currents0.4<Ip<1.8 MA, and at Ip = 1.4 MA with up to 4 MW of ICRH power.