Esteemed listers,

I have the situation that in the vast majority of cases the C program just 
works fine, but in an infinitesimal small number of cases, it gets a S0C4 
abend. I could perhaps, through intricate testing and comparing of lots of 
things -- and burning huge amounts of CPU in doing so -- prevent the abend from 
happening, but I would rather avoid the cost of that testing and instead 
privilege the normal case.

So, I thought to use the signal() function to take control in those very few 
cases where the abend occurs.

However...

signal or no signal, LE takes that CEEDUMP and the program stops, no matter 
what.

What am I missing?

I reduced my program to bare minimum to prove the point. Here is the code:

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef __cplusplus
  extern "C" void StrAbn(int);
#else
  void StrAbn(int);
#endif
int main(int argc, char *argvݨ) {
  printf("Setting abend handler\n");
  if (signal(SIGABND, StrAbn) == SIG_ERR) {
    perror("Could not signal user signal");
    abort();
  } else {
    printf("Abend handler set\n");
  }
  printf("This must cause an abend\n");
  strcpy(0,"Coucou");
  printf("Continuing after abend\n");
  return(0);
}
void StrAbn(int SIG_TYPE) {
  printf("Trapped a vicious abend\n");
  signal(SIG_TYPE, SIG_IGN);
  printf("Exiting after the abend\n");
  exit(0);
}
 
The output says:

Setting abend handler
Abend handler set
This must cause an abend

and it does cause an abend. But control does not come to my signal handling 
routine. The "Trapped a vicious abend" never appears.
I have been reading up on LE condition handling and on the use of the signal() 
function, and I have searched the archives of this very list. All to no avail.

For what it is worth: I do see the following LE options:

ABPERC(NONE)
ABTERMENC(ABEND)
DEBUG
POSIX(OFF)
NOTEST(ALL,"*","PROMPT","INSPPREF")
TRAP(ON,SPIE)
 
So, what do I need to do to actually trap that abend and get control back in my 
program when it happens?

Any and all suggestions are welcome.

Thanks and very best regards,

Jantje.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to