Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/exit.n @ 25

Last change on this file since 25 was 25, checked in by landauf, 16 years ago

added tcl to libs

File size: 1.4 KB
Line 
1'\"
2'\" Copyright (c) 1993 The Regents of the University of California.
3'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4'\"
5'\" See the file "license.terms" for information on usage and redistribution
6'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7'\"
8'\" RCS: @(#) $Id: exit.n,v 1.9 2007/12/13 15:22:32 dgp Exp $
9'\"
10.so man.macros
11.TH exit n "" Tcl "Tcl Built-In Commands"
12.BS
13'\" Note:  do not modify the .SH NAME line immediately below!
14.SH NAME
15exit \- End the application
16.SH SYNOPSIS
17\fBexit \fR?\fIreturnCode\fR?
18.BE
19
20.SH DESCRIPTION
21.PP
22Terminate the process, returning \fIreturnCode\fR to the
23system as the exit status.
24If \fIreturnCode\fR is not specified then it defaults
25to 0.
26.SH EXAMPLE
27Since non-zero exit codes are usually interpreted as error cases by
28the calling process, the \fBexit\fR command is an important part of
29signaling that something fatal has gone wrong. This code fragment is
30useful in scripts to act as a general problem trap:
31.CS
32proc main {} {
33    # ... put the real main code in here ...
34}
35
36if {[catch {main} msg options]} {
37    puts stderr "unexpected script error: $msg"
38    if {[info exist env(DEBUG)]} {
39        puts stderr "---- BEGIN TRACE ----"
40        puts stderr [dict get $options -errorinfo]
41        puts stderr "---- END TRACE ----"
42    }
43
44    # Reserve code 1 for "expected" error exits...
45    \fBexit\fR 2
46}
47.CE
48
49.SH "SEE ALSO"
50exec(n)
51
52.SH KEYWORDS
53exit, process
Note: See TracBrowser for help on using the repository browser.