## Tcl9.0.3/Tk9.0.3 Documentation > Tcl Commands > exit

### Tcl/Tk Applications | Tcl Commands | Tk Commands | [incr Tcl] Package Commands | SQLite3 Package Commands | TDBC Package Commands | tdbc::mysql Package Commands | tdbc::odbc Package Commands | tdbc::postgres Package Commands | tdbc::sqlite3 Package Commands | Thread Package Commands | Tcl C API | Tk C API | [incr Tcl] Package C API | TDBC Package C API

### NAME

exit — 応用譜を終了する End the application

### 構文 SYNOPSIS

exit ?returnCode?

### 説明 DESCRIPTION

処理を終了し､ returnCode をシステムに終了状態として返す｡ returnCode が指定されない時は省略時設定の 0 を返す｡ Terminate the process, returning returnCode to the system as the exit status. If returnCode is not specified then it defaults to 0.

### 用例 EXAMPLE

非零終了番号は呼出し処理から通常は不具合の場合と解釈されるので､この exit 命令は､何か致命的な悪いことが進行していることの重要な知らせの一部である｡このプログラム片は一般的な不良捕捉として行動し､記述譜の中で有用である: Since non-zero exit codes are usually interpreted as error cases by the calling process, the exit command is an important part of signaling that something fatal has gone wrong. This code fragment is useful in scripts to act as a general problem trap:

    proc main {} {
        # 実際の符号命令をここで書く	# ... put the real main code in here ...
    }

    if {[catch {main} msg options]} {
        puts stderr "unexpected script error: $msg"
        if {[info exists env(DEBUG)]} {
            puts stderr "---- BEGIN TRACE ----"
            puts stderr [dict get $options -errorinfo]
            puts stderr "---- END TRACE ----"
        }

        # ｢予想された｣不都合の存在に対する予約済み符号の1は	#  Reserve code 1 for "expected" error exits...
        exit 2
    }

### SEE ALSO

exec

### KEYWORDS

abort, exit, process
Copyright © 1993 The Regents of the University of California.
Copyright © 1994-1996 Sun Microsystems, Inc.