Actual source code: ex2.c

petsc-3.14.6 2021-03-30
Report Typos and Errors

  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:      args: -error_output_stdout
 33:      filter: egrep "(Caught signal number 11 SEGV|Caught signal number 4 Illegal)" | wc -l
 34:      TODO:  Does not always produce exactly expected output on all systems for all runs

 36: TEST*/