Definition | #include <setjmp.h> void longjmp(jmp_buf env, int value);
|
Parameters | jmp_buf env Field in which int value Integer interpreted as the return value of the |
Notes | The behavior is undefined if The function containing the Non-local jumps are useful in the handling of interrupts (see When program execution is resumed, the variables have the same values they would have received following a |
Example | Text I/O in an interactive text editor represents a typical use for #include <stdio.h>
#include <setjmp.h>
#include <signal.h>
FILE *fp;
jmp_buf env;
void intr(int sig)
{
printf("\n ***** You don't want the text? ****** \n");
longjmp(env,0);
}
int main(void)
{
int c; char reply;
setjmp(env);
signal(SIGINT,intr);
printf("Text output? (y?n):\n");
scanf("%1s",&reply); /* Interruption possible with K2 */
if(reply == 'y')
{
fp = fopen("text","r"); /* File text must exist */
while((c=getc(fp)) != EOF)
putc((char)c,stdout); /* Interruption of text output possible
̧ /* with K2 after "please acknowledge" */
}
else printf("No text output\n");
return 0;
}
|
See also | setjmp, signal |