2 '\" Copyright (c) 1993 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 .TH close n 7.5 Tcl "Tcl Built-In Commands"
13 '\" Note: do not modify the .SH NAME line immediately below!
15 close \- Close an open channel.
17 \fBclose \fIchannelId\fR
22 Closes the channel given by \fIchannelId\fR.
25 \fIChannelId\fR must be an identifier for an open channel such as a
26 Tcl standard channel (\fBstdin\fR, \fBstdout\fR, or \fBstderr\fR),
27 the return value from an invocation of \fBopen\fR or \fBsocket\fR, or
28 the result of a channel creation command provided by a Tcl extension.
31 All buffered output is flushed to the channel's output device,
32 any buffered input is discarded, the underlying file or device is closed,
33 and \fIchannelId\fR becomes unavailable for use.
36 If the channel is blocking, the command does not return until all output
38 If the channel is nonblocking and there is unflushed output, the
39 channel remains open and the command
40 returns immediately; output will be flushed in the background and the
41 channel will be closed when all the flushing is complete.
44 If \fIchannelId\fR is a blocking channel for a command pipeline then
45 \fBclose\fR waits for the child processes to complete.
48 If the channel is shared between interpreters, then \fBclose\fR
49 makes \fIchannelId\fR unavailable in the invoking interpreter but has no
50 other effect until all of the sharing interpreters have closed the
52 When the last interpreter in which the channel is registered invokes
53 \fBclose\fR, the cleanup actions described above occur. See the
54 \fBinterp\fR command for a description of channel sharing.
56 Channels are automatically closed when an interpreter is destroyed and
57 when the process exits. Channels are switched to blocking mode, to ensure
58 that all output is correctly flushed before the process exits.
61 The command returns an empty string, and may generate an error if
62 an error occurs while flushing output.
65 file(n), open(n), socket(n), eof(n), Tcl_StandardChannels(3)
68 blocking, channel, close, nonblocking