1Tcl_GetStdChannel(3)        Tcl Library Procedures        Tcl_GetStdChannel(3)
2
3
4
5______________________________________________________________________________
6

NAME

8       Tcl_GetStdChannel,  Tcl_SetStdChannel  -  procedures for retrieving and
9       replacing the standard channels
10

SYNOPSIS

12       #include <tcl.h>
13
14       Tcl_Channel
15       Tcl_GetStdChannel(type)
16
17       Tcl_SetStdChannel(channel, type)
18
19

ARGUMENTS

21       int type (in)                     The identifier for the standard chan‐
22                                         nel  to  retrieve or modify.  Must be
23                                         one  of  TCL_STDIN,  TCL_STDOUT,   or
24                                         TCL_STDERR.
25
26       Tcl_Channel channel (in)          The  channel  to use as the new value
27                                         for the specified standard channel.
28______________________________________________________________________________
29
30

DESCRIPTION

32       Tcl defines three special channels that are used by various I/O related
33       commands  if no other channels are specified.  The standard input chan‐
34       nel has a channel name of stdin and is used  by  read  and  gets.   The
35       standard output channel is named stdout and is used by puts.  The stan‐
36       dard error channel is named stderr and is used  for  reporting  errors.
37       In addition, the standard channels are inherited by any child processes
38       created using exec or open in the absence of any other redirections.
39
40       The standard channels are actually aliases for other  normal  channels.
41       The current channel associated with a standard channel can be retrieved
42       by calling Tcl_GetStdChannel with  one  of  TCL_STDIN,  TCL_STDOUT,  or
43       TCL_STDERR  as  the type.  The return value will be a valid channel, or
44       NULL.
45
46       A new channel can be set for the standard channel specified by type  by
47       calling Tcl_SetStdChannel with a new channel or NULL in the channel ar‐
48       gument.  If the  specified  channel  is  closed  by  a  later  call  to
49       Tcl_Close,  then  the corresponding standard channel will automatically
50       be set to NULL.
51
52       If a non-NULL value for channel is passed  to  Tcl_SetStdChannel,  then
53       that same value should be passed to Tcl_RegisterChannel, like so:
54
55              Tcl_RegisterChannel(NULL, channel);
56
57       This  is  a  workaround  for  a misfeature in Tcl_SetStdChannel that it
58       fails to do some reference counting housekeeping.  This misfeature can‐
59       not be corrected without contradicting the assumptions of some existing
60       code that calls Tcl_SetStdChannel.
61
62       If Tcl_GetStdChannel is called before Tcl_SetStdChannel, Tcl will  con‐
63       struct a new channel to wrap the appropriate platform-specific standard
64       file handle.  If Tcl_SetStdChannel is called before  Tcl_GetStdChannel,
65       then the default channel will not be created.
66
67       If  one  of  the  standard  channels  is set to NULL, either by calling
68       Tcl_SetStdChannel with a NULL channel argument, or by calling Tcl_Close
69       on  the channel, then the next call to Tcl_CreateChannel will automati‐
70       cally set the standard channel with the newly created channel.  If more
71       than  one  standard channel is NULL, then the standard channels will be
72       assigned starting with standard input,  followed  by  standard  output,
73       with standard error being last.
74
75       See Tcl_StandardChannels for a general treatise about standard channels
76       and the behavior of the Tcl library with regard to them.
77
78

SEE ALSO

80       Tcl_Close(3), Tcl_CreateChannel(3), Tcl_Main(3), tclsh(1)
81
82

KEYWORDS

84       standard channel, standard input, standard output, standard error
85
86
87
88Tcl                                   7.5                 Tcl_GetStdChannel(3)
Impressum