Shutting Down the Runtime

You can halt the runtime from COBOL by executing a STOP RUN statement and the runtime terminates normally. Note that this action calls the user-supplied C routine called Shutdown found in "sub.c".

To halt the runtime from C, call the following routine:

void
acu_shutdown( place_cursor )
int     place_cursor;

Example

The following C program calls a single COBOL routine once, passing it one argument. After the COBOL routine returns, it cancels that program and halts. While it is not necessary to cancel the program in this example, the code is shown for completeness.

#include <stdio.h>
#include "sub.h"
main( argc, argv )
int     argc;
char    *argv[];
    {
    struct a_cobol_info cblinfo; 
    Argument cblargs[1]; 
    acu_initv(argc, argv);
    cblargs[0].a_address = "Hello World"; 
    cblargs[0].a_length = 11; 
    memset(&cblinfo, 0, sizeof(cblinfo)); 
    cblinfo.a_cobol_info_size = sizeof(cblinfo); 
    cblinfo.pgm_name = "cblprog"; 
    cblinfo.num_params = 1; 
    cblinfo.params = cblargs; 
    acu_cobol(&cblinfo);   
    acu_cancel( "cblprog" );
    acu_shutdown( 0 );
    exit( 0 );
}

A simple example of "cblprog" might be:

identification division.
program-id.  cblprog.
data division.
linkage section.
77   hello-world     pic x(11).
procedure division using hello-world.
main-logic.
     display hello-world.
     exit program.