What does a train passenger do when he needs to go to the toilet?

I always wonder how a train passenger does it. For example, when I take the Ringbahn (circle line) in Berlin, a trip takes about 60 minutes. I've never experienced a driver needing to use the bathroom quickly. Or what happens if someone suddenly gets stomach problems. I have the same question about DB on "long-distance"…