The Anal sampling mechanism (also known as the anal sampling reflex or anorectal sampling reflex) is a reflex which detects the contents of the rectal vault and prevents the unexpected voiding of feces. The reflex helps prevent fecal incontinence, and allows for voluntary flatulation to occur without also eliminating solid waste, irrespective of the presence of fecal material in the rectal canal.
The physiological basis for the mechanism is poorly understood.
References
Anal sampling mechanism Wikipedia(Text) CC BY-SA