ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Get the return code after executing the program

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get the return code after executing the program

    Hello everyone. In a CL program, another C program is called, which, when completed, returns the code. How to find out the meaning of this code in a CL program?

  • #2
    I do not recommend using the Unix/C "return code" in a CL program... It makes sense to use it in a QShell/PASE environment where you are interacting with Unix shells, but I don't recommend using it in a native program. Instead, I would suggest either (1) pass a code in a parameter that the CL program can use to determine if there was an error. Or, (2) Use *COMP/*ESCAPE messages to indicate success/failure.

    If you absolutely must use the return code, though, it's possible to receive it via the QUSRJOBI API... Search the docs for "user return code".

    Comment


    • #3
      Duplicate message posted by mistake.
      Last edited by Barbara Morris; October 28, 2021, 03:33 PM.

      Comment


      • #4
        It's not possible to reliably get the value returned by a C program. Some of the operating system is written in C, so by the time your CL program gets control, the return code might have been changed from what your program set.

        See the information for "User return code" at https://www.ibm.com/docs/en/i/7.4?to...WMAttrDesc.htm

        User return code. The user-defined return code set by ILE high-level language constructs. An example is the program return code in the C language. This field is scoped to the job and represents the most recent return code set by any thread within the job. Do not use this field. Many operating system functions run C code and change the value of the user return code. Changes to this field occur at times that cannot be predicted or controlled by user programming, even when the job is single-threaded. To receive a value returned by a called program, it is better to provide a parameter to receive that value rather than to rely on this job-scoped user return code field.
        Last edited by Barbara Morris; October 28, 2021, 03:34 PM.

        Comment

        Working...
        X