A user signal routine is registered in the program unit or in the Start-Exit with the function KCX_REG_USER_SIGNAL_HANDLER(), i.e. user-specific signal handling is only activated once this is done.
KCX_UN_REG_USER_SIGNAL_HANDLER() is used to deregister it and thus deactivate it.
Function KCX_REG_USER_SIGNAL_HANDLER()
The function KCX_REG_USER_SIGNAL_HANDLER() requires a function pointer that points to a user signal routine as an argument.
typedef void utm_user_signal_function_t(int *, char *, char *); void KCX_REG_USER_SIGNAL_HANDLER(utm_user_signal_function_t **p2p_user_signal_func_param);
void my_user_signal_handler(int * p_signal_number, char * signal_text, char * stack_info); typedef void utm_user_signal_function_t(int *, char *, char *); static utm_user_signal_function_t * p_user_signal_func; p_user_signal_func = my_user_signal_handler; KCX_REG_USER_SIGNAL_HANDLER(&p_user_signal_func);
Function KCX_UN_REG_USER_SIGNAL_HANDLER()
Calling KCX_UN_REG_USER_SIGNAL_HANDLER() from the application program deregisters, i.e. deactivates, the current user signal routine in openUTM. From this point onwards, the default openUTM error handling is activated.
void KCX_UN_REG_USER_SIGNAL_HANDLER(void);
Programming the signal routine
The user signal routine is always assigned three arguments:
Param-1
The system signal number as a binary variable 4 bytes in length, i.e. data type “int*”.
Param-2
”Printable” explanation of the system signal number, e.g. “Segmentation fault” for signal 11, maximum 255 bytes long and ending with a null byte.
Param-3
Stack information, multi-line and maximum 4096 bytes long, ending with a null byte.
The user signal routine should only initiate “clear-up actions” and terminate the program with PEND RE:
KDCS call RSET,
KDCS call MPUT NE with error info from the user signal routine parameters,
KDCS call PEND RE with KCRN="Follow-up TAC".
Note
The function may not be exited with exit().
static void my_user_signal_handler( int* p_signal_number , char * utm_signal_string , char * utm_stack_string ) { struct kc_ca *pntrCa ; struct spab *pntrSpab; fprintf(stderr, "Error Handler \"my_user_signal_handler\" called:\n" "signal_number %d\n" "utm_signal_string \"%s\"\n" "utm_stack_string \"%s\"\n", *p_signal_number, utm_signal_string, utm_stack_string); fflush(stderr);
This is followed by e.g. KDCS("RSET"), KDCS("MPUT") and KDCS("PENDRE").
utm-signal-number: 8 utm-signal-string: " Arithmetic Exception" utm-stack-string: [5] KCSSIGNAL(signal_nbr = 8) (optimized), at 0xfebb39a8 (line ~2458) in "kcxrtst.c" [6] __sighndlr(0x8, 0x0, 0xffbfbff8, 0x2f1a4, 0x0, 0x0), at 0xfe1ca79c [7] fb(), line 115 in "regsignal.c" [8] fa(), line 104 in "regsignal.c" [9] regsig(kb = 0xfed3a788, spab = 0xfed42808), line 82 in "regsignal.c" [10] KDCCC(iutmhlpar = 0xfed4cdd8), line 855 in "root.c" [11] KDCHLLC(iutmhlpar = 0xfed4cdd8, lgcon = 0x30400) (optimized), at 0xfebb26ac (line ~1922) in "kcxrtst.c" [12] START_TEILPROGRAM(adfptr01 = 0xffbfc940 "F^A") (optimized), at 0xfec0223c (line ~14697) in "kdcrtmm.c" [13] KDCRTMM(RTMM_CALL = 0xffbfd0e4 "KDCRTSI \xfe\xd1\xec`") (optimized), at 0xfebf9af4 (line ~9766) in "kdcrtmm.c" [14] KDCRTSI() (optimized), at 0xfec04dc0 (line ~818) in "kdcrtsi.c" [15] KDCRTST(argc = 80, argv = <value unavailable>, pKDCMDATA = 0x20) (optimized), at 0xfebb1f74 (line ~1786) in "kcxrtst.c" [16] kcxmnt(argc = 9, argv = 0xffbfda74), line 568 in "xirtend.h" [17] main(argc = 9, argv = 0xffbfda74, envp = 0xffbfda9c) (optimized), at 0x13b1c (line ~64) in "mainutm.c"