Important This documentation space contains information about PATROL Agents when deployed in a TrueSight Operations Management environment. If you are a BMC Helix Operations Management user, see PATROL Agent for BMC Helix Operations Management 24.3.01.

atexit()


Specify a user-defined PSL function to be called upon the normal termination of a PSL process.

Syntax

atexit( function_name )

 

Parameter

Parameter

Definition

function_name

string specifying the name of a user-defined PSL function you want to call

Description

Use the atexit() function to specify a user-defined PSL function to be called upon the normal termination of a PSL process. You must define the specified function before the atexit() call, and it must take no arguments. 

The atexit() function is similar to the C atexit() function. The major difference is that, with the PSL atexit() function, only one function can be executed upon normal termination of the process. 

The atexit() function returns one of the following values, indicating whether the call succeeded:

  • 0 -- Success
  • 1 -- User function not defined
  • 2 -- User function accepts too many arguments
  • 3 -- Out of memory

If the return value is non-zero, then the call to atexit() failed, and the function will not be called upon normal termination.

Example

The following is an example of the atexit() function:

function my_exit_handler()
{
# This function must take no arguments and be
# defined before the atexit() call.
print("Hello from 'my_exit_handler'.\n");
}
function main()
{
print("Before the call to atexit()\n");
atexit("my_exit_handler");
print("After the call to atexit()\n");
}

This example returns the following output:

Before the call to atexit()
After the call to atexit()
Hello from 'my_exit_handler'.

Note

The PSL compiler might warn that the function my_exit_handler was not called or exported. This warning can safely be ignored.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*