Forgive me if this is a FAQ, but I am facing a
problem that has annoyed me about Unix for as long as
I can remember. Here's how it works:
I have a deeply recursive procedure that I use extensively.
Being deeply recursive, it eats stack space like crazy.
Eventually, it runs out of process stack segment (or runs
into the stack limit) and gets a SIGSEGV. Fine.
BUT ... in Unix, you can't catch the signal because if you
are out of stack space your signal handler can't activate.
Dumb. But I need to catch it because running out of stack space
in this way is meaningful in my application, and it should
recover gracefully.
SO ... what's the best way to handle this? Surely one of
you hotshot hackers can figure a way to catch the problem?
CONSTRAINTS: ANSI C, POSIX, no alternate threads or stacks,
no alternate implementations of recursion, please.
Ideas?
Thanks
Jim Cordy