Using the IRAM 30m telescope, we have carried out a systematic survey of the millimeter line emission of SO2 and H2S in various categories of 0-rich circumstellar envelopes. The main sample contains 14 OH/IR stars of three classes: IRC objects with intermediate mass-loss rates, very cold OH/IR stars, and OH supergiants. Three lines of SO2 and two lines of H2S were observed. Both molecules were detected in all the stars, with multiline detections in most of them. The J = 5 - 4 line of SiO, present in one of the observed frequency bands, was also detected in all objects. In addition, SO2 was detected in two SRb stars, and H2S in the carbon star IRC+10216. Upper limits were obtained for the emission from 15 other stars, both O- and C-rich. The 86 GHz line of SO was also detected in 5 stars. The lines of SO2 are found to be optically thin with a relatively low rotational excitation temperature (25 - 40 K), in good agreement with the chemical models predicting its photosynthesis in the outer layers of the envelope. The derived maximum abundances (approximately a few 10(-6) by number) also agree reasonably well with these models. The apparent rotational temperature of H2S is inferred to be somewhat larger (approximately 50 - 100 K) and its line profiles appear somewhat narrower, suggesting a location of H2S in inner layers of the envelope which have possibly not yet been fully accelerated. Models we have made for the infrared rotational excitation show that it is possible to account for the observational results with H2S confined to the inner envelope with a relatively large abundance (approximately 10(-5)) and a cutoff radius of less than or similar to 10(16) cm. However, it is difficult to give a satisfactory chemical account of Such a Cutoff radius. It implies either a very low abundance of H (less-than-or-similar to 10(-5)), or a synthesis of H2S on grains. The destruction of' H2S much closer to the star than the destruction radius or H2O is also difficult to explain by photodissociation or grain processes. The overall abundance of sulfur in the gas phase of 0-rich circumstellar envelopes is certainty relatively large, probably at least approximately 50% of the solar abundance. A few outstanding stars are discussed in terms of their peculiarities: the line profiles of the bipolar nebula OH 231.8+4.2 are examined in terms of the pronounced bipolar structure and unusually high velocities within the flow, and the H2S profiles in the Supergiant NML Cygni are possibly affected by the strong and anisotropic external radiation field.