signal test
This commit is contained in:
parent
3e23f7fdb3
commit
08944c8ed0
|
@ -1,4 +1,5 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define DUMBCOPY for (i=0;i< 65536;i++) \
|
||||
destination[i] = source[i]
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void handler(int s)
|
||||
{
|
||||
if (s == SIGBUS) printf(" now got a bus error signal \n");
|
||||
if (s == SIGSEGV) printf(" now got a segmentation violation signal \n");
|
||||
if (s == SIGILL) printf(" now got a illegal instruction signal \n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("begin \n");
|
||||
int *p = NULL;
|
||||
signal(SIGBUS, handler);
|
||||
signal(SIGSEGV, handler);
|
||||
signal(SIGILL, handler);
|
||||
*p = 0;
|
||||
printf("end \n");
|
||||
}
|
Loading…
Reference in New Issue