C语言函数—sin

函数名

signal

功 能

设置某一信号的对应动作

用 法

int signal(int sig, sigfun fname);

程序例

/* This example installs a signal handler routine for SIGFPE, 
   catches an integer overflow condition, makes an adjustment 
   to AX register, and returns. This example program MAY cause 
   your computer to crash, and will produce runtime errors 
   depending on which memory model is used. 
*/ 

#pragma inline 
#include <stdio.h> 
#include <signal.h> 

void Catcher(int sig, int type, int *reglist) 
{ 
   printf("Caught it!n"); 
   *(reglist + 8) = 3;             /* make return AX = 3 */ 
} 

int main(void) 
{ 
   signal(SIGFPE, Catcher); 
   asm     mov     ax,07FFFH       /* AX = 32767 */ 
   asm     inc     ax              /* cause overflow */ 
   asm     into                    /* activate handler */ 

   /* The handler set AX to 3 on return. If that hadn't happened, 
      there would have been another exception when the next 'into' 
      was executed after the 'dec' instruction. */ 
   asm     dec     ax              /* no overflow now */ 
   asm     into                    /* doesn't activate */ 
   return 0; 
} 
  
  
  

如果引用本站的原创文章,请注明原文链接:,本站保留追究责任的权利!
评论已关闭。