Continuation semantics are the traditional way to deal with signals. The idea is that when a signal handler returns, control resumes where it was at the time of the interruption. This is well suited for asynchronous signals in single-threaded processes, as shown in Example 5–1.
This is also used as the exception-handling mechanism in some programming languages, such as PL/1.
unsigned int nestcount; unsigned int A(int i, int j) { nestcount++; if (i==0) return(j+1) else if (j==0) return(A(i-1, 1)); else return(A(i-1, A(i, j-1))); } void sig(int i) { printf("nestcount = %d\n", nestcount); } main() { sigset(SIGINT, sig); A(4,4); }