atexit

Creates a list of functions that are executed on a “last-in, first-out” basis when the NLM exits normally.

Library:LibC
Classification:ANSI
Service:General C Services

Syntax

  #include <stdlib.h> 
   
  int atexit (
     void   (* func) (void));
  

Parameters

func

(IN) Points to the function to be registered as an atexit function.

Return Values

If successful, returns 0. Otherwise, returns a nonzero value and sets errno to one of the following:

Decimal

Name

Description

5

ENOMEM

Insufficient memory to perform the operation.

9

EINVAL

Invalid argument.

105

ENOCONTEXT

No thread library context is present.

Remarks

The atexit functions are called when one of the following occur:

  • The NLM calls exit.

  • The last thread in the NLM calls NXThreadExit and it causes the NLM to be terminated.

  • The last thread in the NLM returns from its original function.

  • The main thread returns from main.

Successive calls to atexit create a list of functions that are executed on a “last-in, first-out” basis.

The atexit functions are not called when one of the following occurs:

  • The UnloadModule function is called. This usually occurs because the unload command for the NLM was enter at the System Console, but it can also occur when another NLM calls this function.

  • One of the threads of the NLM called _exit, abort, or NXVmExit.

See Also