signal/setjmp函数使用举例

#include

#include

#include

 

jmp_buf buf;

 

void handler(int s)

{

       if(SIGINT == s)

       {

              printf("now got a SIGINT signal/n");

       }

       longjmp(buf, 1);

}

 

void main()

{

       signal(SIGINT, handler);

 

       if(setjmp(buf))

       {

              printf("back in main/n");

              return;

       }

       else

       {

              printf("first time through/n");

       }

 

loop:

       goto loop;

}

你可能感兴趣的:(C)