When the DLL it depends on does not exist, the program ended up with ABEND S806/RSN-4, the dump writes:
DESCRIPTION: S806 - A MODULE REQUESTED BY THE PROGRAM COULD NOT BE FOUND.
OK, nothing surprise till now.
But from the SYSPRINT of the job log I noticed that the program actually executed, it even printed out some message until it called the function in the DLL and ABENDed with S806. Therefore I wanted to 'catch' the error and print more error message in order to let it ABEND more gracefully?
I tried to setup signal handler for SIGABEND using the following snippet:
void myHandler(int codeAbend)
{
printf("ABEND %d\n", codeAbend);
exit(4);
}
...
struct sigaction info,newhandler;
newhandler.sa_handler = myHandler;
sigemptyset(&newhandler.sa_mask);
newhandler.sa_flags = 0;
sigaction(SIGABND, &newhandler, &info);
{
printf("ABEND %d\n", codeAbend);
exit(4);
}
...
struct sigaction info,newhandler;
newhandler.sa_handler = myHandler;
sigemptyset(&newhandler.sa_mask);
newhandler.sa_flags = 0;
sigaction(SIGABND, &newhandler, &info);
But neither was the error message printed out, nor was the exit code changed to 4. It still ABENDed with S806.
I checked the return code of sigaction(), it was 0, not SIG_ERR. I also tried ANSI function signal(SIGABND, myHandler), but I still did not make it.
Finally I tried to raise the signal on my own by raise(SIGABND). This is time my program caught the ABEND.
Is there anything I did wrong? Or this kind of ABEND simply cannot be caught at all? If so, why doesn't IBM's document mention it?
Thank you guys very much!
Edited as to font and code tags