atexit()
Specify a user-defined PSL function to be called upon the normal termination of a PSL process.
Syntax
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:
{
# 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:
After the call to atexit()
Hello from 'my_exit_handler'.