A deposition/etching/deposition process is provided for filling a gap in a
surface of a substrate. A liner is formed over the substrate so that
distinctive reaction products are formed when it is exposed to a chemical
etchant. The detection of such reaction products thus indicates that the
portion of the film deposited during the first etching has been removed
to an extent that further exposure to the etchant may remove the liner
and expose underlying structures. Accordingly, the etching is stopped
upon detection of distinctive reaction products and the next deposition
in the deposition/etching/deposition process is begun.