What happens with a baby when its in the womb and it has to go to the bathroom?

Answers:  

do not have bowel movements in the womb, it really stays in there till they are born and it's acall meconium. But they do urinate into the aminatic fluid. It doesn't harm the baby, (he does swallow it later on though) But most waste is passed through the umbilical cord and the mother gets rid of it for them.
Generally babies only pee while in the womb but most don't have a bowel movement. If they do then when the baby is born it has to immediately be sucked out because if the fecal matter is sucked into the babies lungs it can cause serious problems. You would know if the baby had a bm if the amniotic fluid comes out any color than clear. If it's not clear the doctor needs to know asap.
They go they drink the same amniotic fluid and it is replaced about 8-10 times a day it kinda grossed me out at first but it is human nature!!
the umbilical cord carries the waste away

The umbilical cord is the cord that connects the fetus to the maternal placenta, providing nutrients and removing wastes. The umbilical cord is a cordlike structure about 22 in. (56 cm) long in a pregnant woman, extending from the abdominal wall of the fetus to the placenta.

The main function of the umbilical cord is to carry nourishment and oxygen from the placenta to the fetus and return waste products to the placenta from the fetus. The umbilical cord achieves this function by consisting of an extension of the membrane covering the fetus that encloses a mucoid jelly through which one vein carries oxygenated blood and two arteries carry un-oxygenated blood.

Blood is carried from the fetus along the umbilical cord and into the placenta. Here it is brought close to the mother's blood. Oxygen, nutrients, and antibodies from the mother diffuse into the fetal blood and waste materials from the fetus pass into the mother's blood, via the two un-oxygenated arteries. The fetal blood, which has been enriched with nutrients, oxygenated, and cleaned of waste, is then carried back to the fetus by the vein that carries oxygenated blood in the umbilical cord.
At some point babies do begin to pee while in the womb. They usually don't poop until after birth but not in all cases. When in labor the baby had a bowel movement and some how the nurses knew and told me there was going to be a specialist when the baby was born to make sure it's all cleaned out of the baby's lungs. A little scary but everything went fine.
The amniotic fluid IS a babys pee. If they have their fisrt bowl movement before birth, my son did, then that can casue problems if they dont get it out before the baby takes its first breath. It can cause phenmonia and other things which everyone knows can be extremly harmful and sometimes fatal for a newborn.
babies inside the whomb don't,and when they do its a sign that they are ready to go out,and the urine became a real danger on the baby and his mom
usually they dont poop until after they are born, if they do though, they must be taken out right away. but as for pee, they just pee in the womb, its gross but they sit in their own pee while they are in the womb, it doesnt hurt them.
I know this will sound gross but it is true Amnionic fluid IS featal urine. I learned this from my favorite RN during my three week hospital stay before I had my twins

The answers post by the user, for information only, FeelBaby.com does not guarantee the right.