atexit

atexit(f)

Register a zero-argument function f() to be called at process exit. atexit() hooks are called in last in first out (LIFO) order and run before object finalizers.

Examples

julia> function cleanup()
           println("Performing cleanup tasks...")
       end

julia> atexit(cleanup)

julia> exit()
Performing cleanup tasks...

In this example, the cleanup function is registered using atexit(). When exit() is called, either by explicitly quitting Julia or when the program finishes execution, the registered function cleanup() is called, and "Performing cleanup tasks..." is printed.

Note that atexit() hooks are called in Last In First Out (LIFO) order. If multiple functions are registered using atexit(), the last registered function will be executed first, followed by the others in reverse order.

It's important to keep in mind that atexit() hooks are run before object finalizers.

See Also

addprocs, atexit, cd, clipboard, EnvHash, exit, getpid, peakflops, ProcessExitedException, process_exited, process_running, procs, quit, readandwrite, redirect_stdout, rmprocs, run, setenv, spawn, withenv,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: