Chapter Contents

Previous

Next
Library Initialization and Termination Exits

Exit Linkage Conventions

The following sections describe the linkage conventions for the library initialization and termination exits.


L$XSTRT

The SAS/C initialization exit, L$XSTRT, is called by library initialization shortly before control is passed to main . If the indep compiler option is specified, the library calls this exit before control is passed to the first user function.

Linkage for L$XSTRT is defined as follows:

void L$XSTRT(void *user_words [4] );

user_words is a pointer to four words that can be modified to contain information that you specify. On return from L$XSTRT, these words are copied to the four user words in the CRAB that are available to the user and the installation. The program can access these CRAB user words during execution. Refer to The C Run-Time Anchor Block for more information on the CRAB.


L$XFINI

The SAS/C termination exit, L$XFINI, is called by library termination after all atexit routines have been called but before files are closed or signal handling is terminated. L$XFINI receives the program's exit code as a parameter and can change it.

Linkage for L$XFINI is defined as follows:

int L$XFINI(void *user_words [4] , int rc);

user_words is a pointer to four words that contain the current contents of the CRAB user area. These values are the same as those stored by L$XSTRT, unless the CRAB user words were modified during program execution. The rc parameter contains the program's exit code. The library takes the return value from L$XFINI library as an overriding exit code, replacing the exit code specified by the program. If you do not want the program's exit code to be changed, specify return (rc); within the program so that L$XFINI will return the value of rc . The library calls L$XFINI only once during program termination regardless of the number of times that exit is called from the program.

Note that L$XFINI is called only when execution is terminated normally, due to a call to exit or L$UEXIT or due to return from the main function. It is not called if the program is terminated by an ABEND or an unhandled UNIX System Services (USS) signal.


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.