[Python-Dev] Preventing recursion core dumps

Moshe Zadka Moshe Zadka <moshez@math.huji.ac.il>
2000年8月11日 17:13:13 +0300 (IDT)


On 2000年8月11日, Guido van Rossum wrote:
> It would be good if there was a way to sense the remaining available
> stack, even if it wasn't portable. Any Linux experts out there?

I'm far from an expert, but I might have an idea. The question is: must
this works for embedded version of Python, or can I fool around with
main()?
Here's the approach:
 - In main(), get the address of some local variable. Call this
 min
 - Call getrlimit, and see the stack size. Call max = min+ (<stack size )
 - When checking for "too much recursion", take the address of a local 
 variable and compare it against max. If it's higher, stop.
--
Moshe Zadka <moshez@math.huji.ac.il>
There is no IGLU cabal.
http://advogato.org/person/moshez

AltStyle によって変換されたページ (->オリジナル) /