On rec.games.roguelike.nethack, there was once a discussion on whether it is possible for a Nethack character to survive for an infinitely long time. This does not refer to ascension or to explore mode or wizard mode, but to a normal game lasting for infinitely many turns. There are two factors one must control to achieve this: hit points and nutrition. If either falls too low, you die.

The method rgrn chose for keeping your hit points up was to make sure that nothing could ever attack you. Surround yourself with a wall of immobile monsters such as blue jellies to prevent monsters from getting next to you. Then read a scroll of earth to create a wall of boulders on top of the jellies, so that nothing will see you and attempt a ranged attack. You may need to repeat this procedure if some of the jellies don't survive the first time. It may also be necessary to genocide mind flayers and master mind flayers, because of their blasts of psychic energy.

Theoretically it would also be possible to kill so many monsters that all types of monster become extinct - this practice is known as extinctionist play. Extinction doesn't apply to quest levels, I think, but you wouldn't have to stay there. The reason for going to all this trouble to keep your HP from dropping is that, no matter how fast your character heals, it would be impossible to prove that they could kill anything the game threw at them.

Moving on to nutrition, you must either take a form that does not need to eat, or ensure yourself an infinite supply of food. Relying on prayer won't do, because the upper limit to prayer timeout is very large. The poster on rgrn chose to polymorph into a xorn and eat amulets of unchanging until he gained the unchanging intrinsic. (Wearing the amulet won't do, as amulets cause food consumption.)

Ensuring an infinite supply of food is trickier but workable. Once you've been everywhere in the dungeon and rendered every species of monster extinct (which takes a very long, but finite, time), nothing more will be generated. The exception for quest levels still applies, but as before, we can't prove that you'd get enough food to survive there, or that you wouldn't run out of hit points. So what you need is a horn of plenty and the Platinum Yendorian Express Card (to recharge the horn). This is not guaranteed to keep you alive forever - perhaps the horn generates nothing but potions of acid for a very long time. When you use this strategy, the total amount of nutrition available to you, including a stockpile of food you can't eat yet because you are satiated, goes up and down in an unbounded random walk. Your probability of surviving forever is not unity, but since the gain when you get a food ration is much greater than the loss when you get a potion of acid, it is very high.