External Interfaces Reference Previous page   Next Page
mexAtExit

Register subroutine to be called when MEX-file cleared or MATLAB terminates

Fortran Syntax

Arguments

ExitFcn
   The exit function. This function must be declared as external.

Returns

Always returns 0.

Description

Use mexAtExit to register a subroutine to be called just before the MEX-file is cleared or MATLAB is terminated. mexAtExit gives your MEX-file a chance to perform an orderly shutdown of anything under its control.

Each MEX-file can register only one active exit subroutine at a time. If you call mexAtExit more than once, MATLAB uses the ExitFcn from the more recent mexAtExit call as the exit function.

If a MEX-file is locked, all attempts to clear the MEX-file will fail. Consequently, if a user attempts to clear a locked MEX-file, MATLAB does not call the ExitFcn.

You must declare the ExitFcn as external in the Fortran routine that calls mexAtExit if it is not within the scope of the file.

See Also

mexSetTrapFlag


Previous page  Fortran MEX-Functions mexCallMATLAB Next page

© 1994-2005 The MathWorks, Inc.