"When the SIGABND signal is registered with an address of a C handler using the signal() function, control cannot resume at the instruction following the abend or the invocation of raise() with SIGABND. If the C signal handler is returned, the abend is percolated and the default behavior occurs. The longjmp() or exit() function can be invoked from the handler to control the behavior.
"If SIG_IGN is the specified action for SIGABND and an abend occurs (or SIGABND was raised), the abend will not be ignored because a resume cannot occur. The abend will percolate and the default action will occur. https://www.ibm.com/docs/en/zos/2.3.0?topic=SSLTBW_2.3.0/com.ibm.zos.v2r3.cbcpx01/cbc1p2321.htm Joe On Tue, Oct 19, 2021 at 10:03 AM Jantje. < [email protected]> 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
