2: static char help[] = "Tests the signal handler.\n";
4: #include <petscsys.h>
6: int CreateError(int n)
7: {
9: PetscReal *x = 0;
10: if (!n) {x[0] = 100.; return 0;}
11: CreateError(n-1);
12: return 0;
13: }
15: int main(int argc,char **argv)
16: {
18: PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;
19: PetscFPrintf(PETSC_COMM_WORLD,stdout,"Demonstrates how PETSc can trap error interrupts\n");
20: PetscFPrintf(PETSC_COMM_WORLD,stdout,"The error below is contrived to test the code!\n");
21: PetscSynchronizedFlush(PETSC_COMM_WORLD,PETSC_STDOUT);
22: CreateError(5);
23: PetscFinalize();
24: return ierr;
25: }
29: /*TEST
31: test:
32: filter: Error: egrep "(Caught signal number 11 SEGV|Caught signal number 4 Illegal)" | wc -l
35: TEST*/