In 1896 T.M. Montgomery, who was supervising the disinterment of remains at the Fort Randall Cemetery, reported that a little over 2% of those bodies exhumed were definitely victims of being accidentally buried alive. In other words, about 2% woke up, tried to claw their way out, and were unable to do so. Given the oxygen supply in a coffin doesn’t last that long, it is likely the actual percentage of people buried alive was higher, when you include the ones who didn’t wake, but were still technically alive when buried.
In any event, to prevent deaths by burial, a string would supposedly be attached to the finger of the person presumed dead, and it was attached to a bell on the other end above ground. When the person moved, the bell would ring. And that was what you would call a “dead ringer.”
Problem is that concept almost never was carried out.
There is a story of a man who was afraid of this issue so put a “window” through the casket clear up through the ground. I mean it is real. I believe I saw it on a YouTube upload. Shows the current condition of the window. Very small, so not real effective.