1<HTML><HEAD><TITLE>Built-In Commands - exit manual page</TITLE></HEAD><BODY> 2<H3><A NAME="M2">NAME</A></H3> 3exit - End the application 4<H3><A NAME="M3">SYNOPSIS</A></H3> 5<B>exit </B>?<I>returnCode</I>?<BR> 6<H3><A NAME="M4">DESCRIPTION</A></H3> 7Terminate the process, returning <I>returnCode</I> to the 8system as the exit status. 9If <I>returnCode</I> isn't specified then it defaults 10to 0. 11<H3><A NAME="M5">EXAMPLE</A></H3> 12Since non-zero exit codes are usually interpreted as error cases by 13the calling process, the <B>exit</B> command is an important part of 14signalling that something fatal has gone wrong. This code fragment is 15useful in scripts to act as a general problem trap: 16<PRE>proc main {} { 17 # ... put the real main code in here ... 18} 19 20if {[catch {main} msg]} { 21 puts stderr "unexpected script error: $msg" 22 if {[info exist env(DEBUG)]} { 23 puts stderr "---- BEGIN TRACE ----" 24 puts stderr $errorInfo 25 puts stderr "---- END TRACE ----" 26 } 27 28 # Reserve code 1 for "expected" error exits... 29 <B>exit</B> 2 30}</PRE> 31<H3><A NAME="M6">SEE ALSO</A></H3> 32<B><A HREF="../TclCmd/exec.htm">exec</A></B>, <B><A HREF="../TclCmd/tclvars.htm">tclvars</A></B> 33<H3><A NAME="M7">KEYWORDS</A></H3> 34<A href="../Keywords/E.htm#exit">exit</A>, <A href="../Keywords/P.htm#process">process</A> 35<HR><PRE> 36<A HREF="../copyright.htm">Copyright</A> © 1993 The Regents of the University of California. 37<A HREF="../copyright.htm">Copyright</A> © 1994-1996 Sun Microsystems, Inc. 38<A HREF="../copyright.htm">Copyright</A> © 1995-1997 Roger E. Critchlow Jr.</PRE> 39</BODY></HTML> 40