I don't see that praying, as an atheist, in a foxhole, has anything to do with the solidity or constancy of your beliefs. I would think that if I was in a foxhole under fire, I would do absolutely anything that might even conceivably improve my chance of getting my ass out alive. Even if you don't believe there is a God, hedging bets doesn't sound like a bad idea. If there is a God, and She won't listen due to your previous behavior, then either She's a petty God or She simply won't listen, that's all; but faced with death, the chance that maybe She would listen anyway is worth it.