S0C1 and S0C4 are ABENDs and caught by SIGABND; what SIGSEGV catches are 
program checks via an (E)SPIE exit. I'm not sure whether it catches every 
relevant PIC or only 04.

As a side issue, can you catch a data exception, fix the data in the handler 
and retry the way that you can in a PL/I ON unit?


--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3

________________________________________
From: IBM Mainframe Discussion List [[email protected]] on behalf of 
David Crayford [[email protected]]
Sent: Thursday, October 21, 2021 8:22 PM
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

Reply via email to