When an astronaut, dressed in an elaborate spacesuit, is in his capsule hurtling through space at a tremendous speed, and perhaps consuming one of the hydratable delicacies prepackaged for him, relieving himself is not the problem it appears to be.
Toilet facilities on the spacecraft are quite simple.
The astronaut attaches a plastic bag with an adhesive lip near his anal opening. When full, the bag, which contains a germicide to prevent bacteria and gas formation, is sealed and stored in an empty food container for analysis after the flight.
To urinate, the astronaut uses a fitted receptacle connected by a hose to a collection device where urine may be stored. In some NASA flights, urine was simply dumped overboard.