📄 stdchannels.3
字号:
'\"'\" Copyright (c) 2001 by ActiveState Corporation'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" RCS: @(#) $Id: StdChannels.3,v 1.8 2002/11/15 15:34:17 dkf Exp $'\" .so man.macros.TH "Standard Channels" 3 7.5 Tcl "Tcl Library Procedures".BS'\" Note: do not modify the .SH NAME line immediately below!.SH NAMETcl_StandardChannels \- How the Tcl library deals with the standard channels.BE.SH DESCRIPTION.PPThis page explains the initialization and use of standard channels inthe Tcl library..PPThe term \fIstandard channels\fR comes out of the Unix world andrefers to the three channels automatically opened by the OS foreach new application. They are \fBstdin\fR, \fBstdout\fR and\fBstderr\fR. The first is the standard input an application can readfrom, the other two refer to writable channels, one for regularoutput and the other for error messages..PPTcl generalizes this concept in a cross-platform way andexposes standard channels to the script level..SH APIs.PPThe public API procedures dealing directly with standard channels are\fBTcl_GetStdChannel\fR and \fBTcl_SetStdChannel\fR. Additional publicAPIs to consider are \fBTcl_RegisterChannel\fR,\fBTcl_CreateChannel\fR and \fBTcl_GetChannel\fR..SH "INITIALIZATION OF TCL STANDARD CHANNELS".PPStandard channels are initialized by the Tcl library in three cases:when explicitly requested, when implicitly required before returningchannel information, or when implicitly required during registrationof a new channel..PPThese cases differ in how they handle unavailable platform- specificstandard channels. (A channel is not ``available'' if it could not besuccessfully opened; for example, in a Tcl application run as aWindows NT service.).TP1)A single standard channel is initialized when it is explicitlyspecified in a call to \fBTcl_SetStdChannel\fR. The state of theother standard channels are unaffected..spMissing platform-specific standard channels do not matter here. Thisapproach is not available at the script level..TP2)All uninitialized standard channels are initialized toplatform-specific default values:.RS.TP(a)when open channels are listed with \fBTcl_GetChannelNames\fR (or the\fBfile channels\fR script command), or.TP(b)when information about any standard channel is requested with a callto \fBTcl_GetStdChannel\fR, or with a call to \fBTcl_GetChannel\fRwhich specifies one of the standard names (\fBstdin\fR, \fBstdout\fRand \fBstderr\fR)..RE.sp.RSIn case of missing platform-specific standard channels, the Tclstandard channels are considered as initialized and then immediatelyclosed. This means that the first three Tcl channels then opened bythe application are designated as the Tcl standard channels..RE.TP3)All uninitialized standard channels are initialized toplatform-specific default values when a user-requested channel isregistered with \fBTcl_RegisterChannel\fR..spIn case of unavailable platform-specific standard channels the channelwhose creation caused the initialization of the Tcl standard channelsis made a normal channel. The next three Tcl channels opened by theapplication are designated as the Tcl standard channels. In otherwords, of the first four Tcl channels opened by the application thesecond to fourth are designated as the Tcl standard channels..PP.SH "RE-INITIALIZATION OF TCL STANDARD CHANNELS".PPOnce a Tcl standard channel is initialized through one of the methodsabove, closing this Tcl standard channel will cause the next call to\fBTcl_CreateChannel\fR to make the new channel the new standardchannel, too. If more than one Tcl standard channel was closed\fBTcl_CreateChannel\fR will fill the empty slots in the order\fBstdin\fR, \fBstdout\fR and \fBstderr\fR..PP\fBTcl_CreateChannel\fR will not try to reinitialize an empty slot ifthat slot was not initialized before. It is this behavior whichenables an application to employ method 1 of initialization, i.e. tocreate and designate their own Tcl standard channels..SH tclsh.PPThe Tcl shell (or rather \fBTcl_Main\fR) uses method 2 to initializethe standard channels..SH wish.PPThe windowing shell (or rather \fBTk_MainEx\fR) uses method 1 toinitialize the standard channels (See \fBTk_InitConsoleChannels\fR)on non-Unix platforms. On Unix platforms, \fBTk_MainEx\fR implicitlyuses method 2 to initialize the standard channels..SH "SEE ALSO"Tcl_CreateChannel(3), Tcl_RegisterChannel(3), Tcl_GetChannel(3), Tcl_GetStdChannel(3), Tcl_SetStdChannel(3), Tk_InitConsoleChannels(3), tclsh(1), wish(1), Tcl_Main(3), Tk_MainEx(3).SH KEYWORDSstandard channels
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -