Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/StdChannels.3 @ 42

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

added tcl to libs

File size: 4.8 KB
Line 
1'\"
2'\" Copyright (c) 2001 by ActiveState Corporation
3'\"
4'\" See the file "license.terms" for information on usage and redistribution
5'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6'\"
7'\" RCS: @(#) $Id: StdChannels.3,v 1.14 2007/12/13 15:22:32 dgp Exp $
8'\"
9.so man.macros
10.TH "Standard Channels" 3 7.5 Tcl "Tcl Library Procedures"
11.BS
12'\" Note:  do not modify the .SH NAME line immediately below!
13.SH NAME
14Tcl_StandardChannels \- How the Tcl library deals with the standard channels
15.BE
16
17.SH DESCRIPTION
18.PP
19This page explains the initialization and use of standard channels in
20the Tcl library.
21.PP
22The term \fIstandard channels\fR comes out of the Unix world and
23refers to the three channels automatically opened by the OS for
24each new application. They are \fBstdin\fR, \fBstdout\fR and
25\fBstderr\fR. The first is the standard input an application can read
26from, the other two refer to writable channels, one for regular
27output and the other for error messages.
28.PP
29Tcl generalizes this concept in a cross-platform way and
30exposes standard channels to the script level.
31.SS "APPLICATION PROGRAMMING INTERFACES"
32.PP
33The public API procedures dealing directly with standard channels are
34\fBTcl_GetStdChannel\fR and \fBTcl_SetStdChannel\fR. Additional public
35APIs to consider are \fBTcl_RegisterChannel\fR,
36\fBTcl_CreateChannel\fR and \fBTcl_GetChannel\fR.
37.SH "INITIALIZATION OF TCL STANDARD CHANNELS"
38.PP
39Standard channels are initialized by the Tcl library in three cases:
40when explicitly requested, when implicitly required before returning
41channel information, or when implicitly required during registration
42of a new channel.
43.PP
44These cases differ in how they handle unavailable platform- specific
45standard channels.  (A channel is not
46.QW available
47if it could not be
48successfully opened; for example, in a Tcl application run as a
49Windows NT service.)
50.TP
511)
52A single standard channel is initialized when it is explicitly
53specified in a call to \fBTcl_SetStdChannel\fR.  The states of the
54other standard channels are unaffected.
55.RS
56.PP
57Missing platform-specific standard channels do not matter here. This
58approach is not available at the script level.
59.RE
60.TP
612)
62All uninitialized standard channels are initialized to
63platform-specific default values:
64.RS
65.TP
66(a)
67when open channels are listed with \fBTcl_GetChannelNames\fR (or the
68\fBfile channels\fR script command), or
69.TP
70(b)
71when information about any standard channel is requested with a call
72to \fBTcl_GetStdChannel\fR, or with a call to \fBTcl_GetChannel\fR
73which specifies one of the standard names (\fBstdin\fR, \fBstdout\fR
74and \fBstderr\fR).
75.PP
76In case of missing platform-specific standard channels, the Tcl
77standard channels are considered as initialized and then immediately
78closed. This means that the first three Tcl channels then opened by
79the application are designated as the Tcl standard channels.
80.RE
81.TP
823)
83All uninitialized standard channels are initialized to
84platform-specific default values when a user-requested channel is
85registered with \fBTcl_RegisterChannel\fR.
86.PP
87In case of unavailable platform-specific standard channels the channel
88whose creation caused the initialization of the Tcl standard channels
89is made a normal channel.  The next three Tcl channels opened by the
90application are designated as the Tcl standard channels.  In other
91words, of the first four Tcl channels opened by the application the
92second to fourth are designated as the Tcl standard channels.
93.SH "RE-INITIALIZATION OF TCL STANDARD CHANNELS"
94.PP
95Once a Tcl standard channel is initialized through one of the methods
96above, closing this Tcl standard channel will cause the next call to
97\fBTcl_CreateChannel\fR to make the new channel the new standard
98channel, too. If more than one Tcl standard channel was closed
99\fBTcl_CreateChannel\fR will fill the empty slots in the order
100\fBstdin\fR, \fBstdout\fR and \fBstderr\fR.
101.PP
102\fBTcl_CreateChannel\fR will not try to reinitialize an empty slot if
103that slot was not initialized before. It is this behavior which
104enables an application to employ method 1 of initialization, i.e. to
105create and designate their own Tcl standard channels.
106.SH "SHELL-SPECIFIC DETAILS"
107.SS tclsh
108.PP
109The Tcl shell (or rather the function \fBTcl_Main\fR, which forms the
110core of the shell's implementation) uses method 2 to initialize
111the standard channels.
112.SS wish
113.PP
114The windowing shell (or rather the function \fBTk_MainEx\fR, which
115forms the core of the shell's implementation) uses method 1 to
116initialize the standard channels (See \fBTk_InitConsoleChannels\fR)
117on non-Unix platforms.  On Unix platforms, \fBTk_MainEx\fR implicitly
118uses method 2 to initialize the standard channels.
119.SH "SEE ALSO"
120Tcl_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)
121.SH KEYWORDS
122standard channels
Note: See TracBrowser for help on using the repository browser.