Tcl Library Procedures Tcl_GetStdChannel(3TCL)
_________________________________________________________________
NAME
Tcl_GetStdChannel, Tcl_SetStdChannel - procedures for
retrieving and replacing the standard channelsSYNOPSIS
#include
Tcl_Channel
Tcl_GetStdChannel(type)
Tcl_SetStdChannel(channel, type)
ARGUMENTS int type (in) The identifier for the standard channel to retrieve or modify. Mustbe one of TCL_STDIN,
TCL_STDOUT, or TCL_STDERR.
Tcl_Channel channel (in) The channel to use as the
new value for the speci-
fied standard channel._________________________________________________________________
DESCRIPTION
Tcl defines three special channels that are used by variousI/O related commands if no other channels are specified. The standard input channel has a channel name of stdin and is used by read and gets. The standard output channel is
named stdout and is used by puts. The standard error chan-
nel is named stderr and is used for reporting errors. In addition, the standard channels are inherited by any child processes created using exec or open in the absence of any other redirections. The standard channels are actually aliases for other normal channels. The current channel associated with a standardchannel can be retrieved by calling Tcl_GetStdChannel with
one of TCL_STDIN, TCL_STDOUT, or TCL_STDERR as the type.
The return value will be a valid channel, or NULL. A new channel can be set for the standard channel specifiedby type by calling Tcl_SetStdChannel with a new channel or
NULL in the channel argument. If the specified channel isclosed by a later call to Tcl_Close, then the corresponding
standard channel will automatically be set to NULL. Tcl Last change: 7.5 1Tcl Library Procedures Tcl_GetStdChannel(3TCL)
If a non-NULL value for channel is passed to
Tcl_SetStdChannel, then that same value should be passed to
Tcl_RegisterChannel, like so:
Tcl_RegisterChannel(NULL, channel);
This is a workaround for a misfeature in Tcl_SetStdChannel
that it fails to do some reference counting housekeeping. This misfeature cannot be corrected without contradicting the assumptions of some existing code that callsTcl_SetStdChannel.
If Tcl_GetStdChannel is called before Tcl_SetStdChannel, Tcl
will construct a new channel to wrap the appropriateplatform-specific standard file handle. If
Tcl_SetStdChannel is called before Tcl_GetStdChannel, then
the default channel will not be created. If one of the standard channels is set to NULL, either bycalling Tcl_SetStdChannel with a NULL channel argument, or
by calling Tcl_Close on the channel, then the next call to
Tcl_CreateChannel will automatically set the standard chan-
nel with the newly created channel. If more than one stan-
dard channel is NULL, then the standard channels will be assigned starting with standard input, followed by standard output, with standard error being last.See Tcl_StandardChannels for a general treatise about stan-
dard channels and the behaviour of the Tcl library with regard to them.SEE ALSO
Tcl_Close(3TCL), Tcl_CreateChannel(3TCL), Tcl_Main(3TCL),
tclsh(1) KEYWORDS standard channel, standard input, standard output, standard errorATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes: Tcl Last change: 7.5 2Tcl Library Procedures Tcl_GetStdChannel(3TCL)
_______________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE|
|____________________|__________________|_
| Availability | runtime/tcl-8 |
|____________________|__________________|_
| Interface Stability| Uncommitted ||____________________|_________________|
NOTES Source for Tcl is available on http://opensolaris.org. Tcl Last change: 7.5 3