Name

exit — terminate execution and child process

Synopsis

::rivet::exit ?code?

Description

Replaces Tcl's exit core command. ::rivet::exit interrupts execution of the current script and passes execution to AbortScript if such script is set. After AbortScript has finished and request processing completed the child process is forced to exit by eventually calling Tcl_Exit producing the same final effect of the core command. During an AbortScript execution the exit condition can be detected

if {[::rivet::abort_page -exiting]} {
...handle exit condition
}

::rivet::exit has a single optional argument ?code?. This value must be a positive integer number to be passed to Tcl_Exit. If any other value is given ?code? is set to 0. The exit code can be obtained from the dictionary returned by ::rivet::abort_code

[::rivet::abort_code]
<== return_code  ?code? error_code exit

Rivet's specific implementation prevents any abrupt process termination that otherwise the exit command would bring about deferring the call to Tcl_Exit to a later stage when the request processing has finished. This is always true if the mod_rivet runs the prefork bridge. The behavior with the worker bridge depends on the SingleThreadExit configuration directive. By default all the threads of a single process are requested to exit before the child process exits. Starting with version 3.2 by setting the SingleThreadExit option directive calling ::rivet::exit causes a single thread termination. Though always accepted this directive is meaningful only if used with the worker or lazy bridges.

[Note]Note
Nonetheless we discourage the programmer to use such command, and suggest to focus on proper application design and avoid such a drastic way to bail out. If you need to restart the child processes from time to time we recommend to check the MaxRequests parameter in the prefork MPM documentation or the MaxRequestsPerChild configuration parameter