Assume an average of 6 characters per word assume

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: rence is that we have installed the handler with a call to Signal rather than a call to signal. The program now runs correctly on both our Solaris and Linux systems, and we no longer need to manually restart interrupted read system calls. 8.6 Nonlocal Jumps C provides a form of user-level exceptional control flow, called a nonlocal jump, that transfers control directly from one function to another currently executing function, without having to go through the normal call-and-return sequence. Nonlocal jumps are provided by the setjmp and longjmp functions. #include <setjmp.h> int setjmp(jmp buf env); int sigsetjmp(sigjmp buf env, int savesigs); returns: 0 from setjmp, nonzero from longjmps) The setjmp function saves the current stack context in the env buffer, for later use by longjmp, and 8.6. NONLOCAL JUMPS 437 code/ecf/signal4.c 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 #include "csapp.h" void handler2(int sig) { pid_t pid;...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online