How do I safely connect a tunnel to a river to pipe away water?

I was building a small reservoir to support a well, and so had a tunnel from this to my local river to act as a filling pipe. All was ready, so I marked the last square between the tunnel and river to be channelled.

A short while later I spotted a lone dwarf running down the pipe tunnel being chased by a wall of water. Luckily I was able to shut the flood gate and build some steps for him to escape before he drowned, but I'd rather avoid this situation in the future!

I presume this dwarf channelled the square and somehow ended up on the ramp square, then decided to run away from the water - straight in to the pipe tunnel?

How can I prevent my dwarfs from doing this in the future?
Or, is there a safer way to connect a "pipe" tunnel to a water source?


I know it's not much of an answer, but the method I usually use is to make sure there's an up stair at the end of the tunnel, dig out the other end, have the dwarf run up, away from the water and then building a floor on the Z-level above it to cover the hole.

Dwarves are stupid. That's just a game mechanic.


Well, in the comments to the answer, tzenes accidentally nudged me to the answer I think I'm happiest with, which is to block the tunnel so the dwarf cannot enter.

In other words, dig out the "pipe" tunnel so it's one square from the river, in the last square of this tunnel put an obstruction that blocks dwarfs but can let water through (linked flood gate or fortification), then channel the connecting square.

The result is that the dwarf cannot enter the tunnel, and so has to just step out of the channelled hole if, for whatever stupid reason, they enter it.