TCL_STANDARDCHANNELS(3tcl)
โจ Standard Channels โ the Tcl Library Procedures tea ๐
okay bestie, so this page is literally all about Tcl_StandardChannels โ aka how the Tcl library deals with the standard channels. yes, the manual is filed under Standard Channels(3tcl) in the Tcl Library Procedures section, and we're gonna get into it. ๐ซถ
๐ธ NAME ๐ธ
Tcl_StandardChannels โ How the Tcl library deals with the standard channels
๐ DESCRIPTION ๐
This page explains the initialization and use of standard channels in the Tcl library. no gatekeeping here, we're telling you everything.
The term standard channels comes out of the Unix world and refers to the three channels automatically opened by the OS for each new application. They are stdin, stdout and stderr. The first is the standard input an application can read from, the other two refer to writable channels, one for regular output and the other for error messages. the original trio, the founding mothers, the blueprint. ๐
Tcl generalizes this concept in a cross-platform way and exposes standard channels to the script level. periodt.
๐ APPLICATION PROGRAMMING INTERFACES ๐
The public API procedures dealing directly with standard channels are Tcl_GetStdChannel and Tcl_SetStdChannel. Additional public APIs to consider are Tcl_RegisterChannel, Tcl_CreateChannel and Tcl_GetChannel. those are the ones in the group chat. โจ
๐ INITIALIZATION OF TCL STANDARD CHANNELS ๐
Standard channels are initialized by the Tcl library in three cases:
- when explicitly requested,
- when implicitly required before returning channel information,
- or when implicitly required during registration of a new channel.
These cases differ in how they handle unavailable platform-specific standard channels. (a channel is not "available" if it could not be successfully opened; for example, in a Tcl application run as a Windows NT service. ๐ญ)
- A single standard channel is initialized when it is explicitly specified in a call to
Tcl_SetStdChannel. The states of the other standard channels are unaffected.
Missing platform-specific standard channels do not matter here. This approach is not available at the script level.
- All uninitialized standard channels are initialized to platform-specific default values:
- (a) when open channels are listed with
Tcl_GetChannelNames(or thefile channelsscript command), or - (b) when information about any standard channel is requested with a call to
Tcl_GetStdChannel, or with a call toTcl_GetChannelwhich specifies one of the standard names (stdin,stdoutandstderr).
- (a) when open channels are listed with
In case of missing platform-specific standard channels, the Tcl standard channels are considered as initialized and then immediately closed. This means that the first three Tcl channels then opened by the application are designated as the Tcl standard channels. plot twist, but a valid one. ๐
- All uninitialized standard channels are initialized to platform-specific default values when a user-requested channel is registered with
Tcl_RegisterChannel.
In case of unavailable platform-specific standard channels the channel whose creation caused the initialization of the Tcl standard channels is made a normal channel. The next three Tcl channels opened by the application are designated as the Tcl standard channels. In other words, of the first four Tcl channels opened by the application the second to fourth are designated as the Tcl standard channels. math is math-ing, bestie. ๐งฎโจ
๐ฆ RE-INITIALIZATION OF TCL STANDARD CHANNELS ๐ฆ
Once a Tcl standard channel is initialized through one of the methods above, closing this Tcl standard channel will cause the next call to Tcl_CreateChannel to make the new channel the new standard channel, too. If more than one Tcl standard channel was closed Tcl_CreateChannel will fill the empty slots in the order stdin, stdout and stderr.
Tcl_CreateChannel will not try to reinitialize an empty slot if that slot was not initialized before. It is this behavior which enables an application to employ method 1 of initialization, i.e. to create and designate their own Tcl standard channels. main character energy fr fr. ๐
๐ธ SHELL-SPECIFIC DETAILS ๐ธ
๐ tclsh
The Tcl shell (or rather the function Tcl_Main, which forms the core of the shell's implementation) uses method 2 to initialize the standard channels.
๐ wish
The windowing shell (or rather the function Tk_MainEx, which forms the core of the shell's implementation) uses method 1 to initialize the standard channels (See Tk_InitConsoleChannels) on non-Unix platforms. On Unix platforms, Tk_MainEx implicitly uses method 2 to initialize the standard channels. different platforms, different strategies, both iconic. ๐
๐ SEE ALSO ๐
Tcl_CreateChannel(3tcl)Tcl_RegisterChannel(3tcl)Tcl_GetChannel(3tcl)Tcl_GetStdChannel(3tcl)Tcl_SetStdChannel(3tcl)Tk_InitConsoleChannels(3tk)tclsh(1)wish(1)Tcl_Main(3tcl)Tk_MainEx(3tk)
โญ KEYWORDS โญ
standard channels
and that's the whole page, bestie, no cap. this one's from Tcl 7.5, dated with the Standard Channels(3tcl) footer energy โ go forth and channel responsibly ๐โจ๐
๐ฆ where this page comes from
- debian trixie: tcl9.0-doc 9.0.1+dfsg-2
- ubuntu questing: tcl9.0-doc 9.0.2+dfsg-1
- ubuntu resolute: tcl9.0-doc 9.0.3+dfsg-1
- ubuntu stonking: tcl9.0-doc 9.0.4+dfsg-1
- Copyright (c) 2001 ActiveState Corporation
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms