Quote Originally Posted by s1mon
Why? The signal handler should do as little as possible - for example, changing a global variable. Then it is your main code's job of checking for that variable. The op can just break out of the loop and proceed with shutdown code on a signal. Otherwise, every time you make changes to your code, you need to change the signal handler code.

However, doesn't signal() only need to be executed once for each signal you want handled, not repeatedly in the loop?
Often you want to terminate a program because it is not responding, if you do it the way
you describe chances are it will not work.