Register a script to be executed when the current connection closes
Syntax
ns_atclose {script | procname ?args?}
Description
ns_atclose adds the specified script or procedure (procname) to a list
of scripts that are invoked when the current connection ends. The
scripts are invoked in the reverse order in which they were
registered. The scripts still get run if the connection closes early,
or if there are Tcl errors following the script registration. If
ns_atclose is invoked within a scheduled procedure, the atclose
handler is invoked at the end of each scheduled execution of the
procedure.
Example
This example makes a temporary file that gets deleted when the
connection ends:
proc show_at_close { } {
set tmpfile [ns_tmpnam]
# open tmpfile, write stuff to it and close it
ns_atclose "ns_unlink -nocomplain $tmpfile"
return $tmpfile
} ;# show_at_close