× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



If all you're doing is calling an RPG program, why don't you do it in CL and
use MONMSG to handle any errors?

If you still want to stick with C, you can use "system" api (i.e.
system("CALL MYRPGPGM") as that doesn't signal any errors but rather returns
an error code that you can ignore.
If you want to do a printf for logging purposes, you can check the error
code for success.

Elvis

-----Original Message-----
Subject: [C400-L] Exception Handling

Hi all,
we have an old RPG OPM project. The project is very sensitive. So sensitive 
that we cannot allow any unhandled exceptions to happen. So I was thinking 
to wrap every call to the project's programs in a C program (I don't know 
RPG good enough), that will handle signals in the following way:

#pragma map(action, "PROGA")
#pragma linkage(action, OS)

jmp_buf jumper;
void action (......)

void signal_handler (int signum)
{
  longjmp(jumper, 1);
}

int main(int argc, const char **argv) {
  struct sigaction act, old;

  /* Set up the signal handler */
  act.sa_handler = signal_handler;
  act.sa_flags = 0;
  sigemptyset (&act.sa_mask);
  sigaction (SIGSEGV, &act, &old);

  if (setjmp(jumper) != 0){
    sigaction (SIGSEGV, &old, NULL);
    printf("General error: SIGSEGV occured");
    // allways return with success
    return EXIT_SUCCESS;
  }

  // CALL RPG program here
  action (...) ;
}

Is it the correct approach at all?
If yes, is SIGSEGV signal enough to handle all possible exeptions in RPG 
program?


Thanks in advance.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.