signal handling while in a function other than main

Hi,

I have a main loop which calls a sub loop, which finally returns to the main loop itself. The main loop runs when a flag is set. Now, I have a signal handler for SIGINT, which resets the flag and thus stops the main loop. Suppose I send SIGINT while the program is in subloop, I get an error (Segmentation fault). gdb says that Program received signal SIGINT, Interrupt. Switching to Thread -so and so (LWP so and so)] etc. I am not able to figure out why this happens, or how to solve it. Does anybody have any ideas ?

Thanks.

Look at the man pages for siglongjmp() or longjmp().

I don't know how that would fix your Seg fault error. Perhaps you havenot called signal() with the proper values?