You will also want TRAP(OFF) in your LE options otherwise LE will always intercept any abend.
Robin -----Original Message----- From: IBM Mainframe Discussion List <[email protected]> On Behalf Of David Crayford Sent: 22 October 2021 07:23 To: [email protected] Subject: Re: C signal() and abends not being signaled You're using the wrong signal. SIGABND catches abends such as x37. If you want to catch machine checks use SIGSEGV (0C4), SIGILL (0C1) etc. On 19/10/2021 11:03 pm, Jantje. wrote: > 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 [email protected] with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
