_GetExcData() — Get Exception Data

Format

#include <signal.h>
void _GetExcData(_INTRPT_Hndlr_Parms_T *parms);

Language Level: ILE C Extension

Threadsafe: Yes.

Job CCSID Interface: All character data sent to this function is expected to be in the CCSID of the job. All character data returned by this function is in the CCSID of the job. See Understanding CCSIDs and Locales for more information.

Description

The _GetExcData() function returns information about the current exception from within a C signal handler. The caller of the _GetExcData() function must allocate enough storage for a structure of type _INTRPT_Hndlr_Parms_T. If the _GetExcData() function is called from outside a signal handler, the storage pointed to by parms is not updated.

This function is not available when SYSIFCOPT(*ASYNCSIGNAL) is specified on the compilation commands. When SYSIFCOPT(*ASYNCSIGNAL) is specified, a signal handler established with the ILE C signal() function has no way to access any exception information that might have caused the signal handler to be invoked. An extended signal handler established with the sigaction() function, however, does have access to this exception information. The extended signal handler has the following function prototype:

void func( int signo, siginfo_t *info, void *context )

The exception information is appended to the siginfo_t structure, which is then passed as the second parameter to the extended signal handler.

The siginfo_t structure is defined in signal.h. The exception-related data follows the si_sigdata field in the siginfo_tstructure. You can address it from the se_data field of the sigdata_t structure.

The format of the exception data appended to the siginfo_t structure is defined by the _INTRPT_Hndlr_Parms_T structure in except.h.

Return Value

There is no return value.

Example that uses _GetExcData()

This example shows how exceptions from MI library functions can be monitored and handled using a signal handling function. The signal handler my_signal_handler is registered before the rslvsp() function signals a 0x2201 exception. When a SIGSEGV signal is raised, the signal handler is called. If an 0x2201 exception occurred, the signal handler calls the QUSRCRTS API to create a space.

#include  <signal.h>
#include  <QSYSINC/MIH/RSLVSP>
#include  <QSYSINC/H/QUSCRTUS>
#include  <string.h>
 
#define CREATION_SIZE  65500
 
void my_signal_handler(int sig) {
 
   _INTRPT_Hndlr_Parms_T excp_data;
   int                   error_code = 0;
 
   /* Check the message id for exception 0x2201 */
   _GetExcData(&excp_data);
 
   if (!memcmp(excp_data.Msg_Id, "MCH3401", 7))
      QUSCRTUS("MYSPACE   QTEMP     ",
               "MYSPACE   ",
               CREATION_SIZE,
               "\0",
               "*ALL      ",
               "MYSPACE example for Programmer's Reference        ",
               "*YES      ",
               &error_code);
}
 

Related Information



[ Top of Page | Previous Page | Next Page | Contents | Index ]