Debian Codegraph @

doc/GetStdChan.3

raw
1 '\"
2 '\" Copyright (c) 1996 Sun Microsystems, Inc.
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 .TH Tcl_GetStdChannel 3 7.5 Tcl "Tcl Library Procedures"
8 .so man.macros
9 .BS
10 '\" Note: do not modify the .SH NAME line immediately below!
11 .SH NAME
12 Tcl_GetStdChannel, Tcl_SetStdChannel \- procedures for retrieving and replacing the standard channels
13 .SH SYNOPSIS
14 .nf
15 \fB#include <tcl.h>\fR
16 .sp
17 Tcl_Channel
18 \fBTcl_GetStdChannel\fR(\fItype\fR)
19 .sp
20 \fBTcl_SetStdChannel\fR(\fIchannel, type\fR)
21 .sp
22 .SH ARGUMENTS
23 .AS Tcl_Channel channel
24 .AP int type in
25 The identifier for the standard channel to retrieve or modify. Must be one of
26 \fBTCL_STDIN\fR, \fBTCL_STDOUT\fR, or \fBTCL_STDERR\fR.
27 .AP Tcl_Channel channel in
28 The channel to use as the new value for the specified standard channel.
29 .BE
30
31 .SH DESCRIPTION
32 .PP
33 Tcl defines three special channels that are used by various I/O related
34 commands if no other channels are specified. The standard input channel
35 has a channel name of \fBstdin\fR and is used by \fBread\fR and \fBgets\fR.
36 The standard output channel is named \fBstdout\fR and is used by
37 \fBputs\fR. The standard error channel is named \fBstderr\fR and is used for
38 reporting errors. In addition, the standard channels are inherited by any
39 child processes created using \fBexec\fR or \fBopen\fR in the absence of any
40 other redirections.
41 .PP
42 The standard channels are actually aliases for other normal channels. The
43 current channel associated with a standard channel can be retrieved by calling
44 \fBTcl_GetStdChannel\fR with one of
45 \fBTCL_STDIN\fR, \fBTCL_STDOUT\fR, or \fBTCL_STDERR\fR as the \fItype\fR. The
46 return value will be a valid channel, or NULL.
47 .PP
48 A new channel can be set for the standard channel specified by \fItype\fR
49 by calling \fBTcl_SetStdChannel\fR with a new channel or NULL in the
50 \fIchannel\fR argument. If the specified channel is closed by a later call to
51 \fBTcl_Close\fR, then the corresponding standard channel will automatically be
52 set to NULL.
53 .PP
54 If a non-NULL value for \fIchannel\fR is passed to \fBTcl_SetStdChannel\fR,
55 then that same value should be passed to \fBTcl_RegisterChannel\fR, like so:
56 .PP
57 .CS
58 Tcl_RegisterChannel(NULL, channel);
59 .CE
60 .PP
61 This is a workaround for a misfeature in \fBTcl_SetStdChannel\fR that it
62 fails to do some reference counting housekeeping. This misfeature cannot
63 be corrected without contradicting the assumptions of some existing
64 code that calls \fBTcl_SetStdChannel\fR.
65 .PP
66 If \fBTcl_GetStdChannel\fR is called before \fBTcl_SetStdChannel\fR, Tcl will
67 construct a new channel to wrap the appropriate platform-specific standard
68 file handle. If \fBTcl_SetStdChannel\fR is called before
69 \fBTcl_GetStdChannel\fR, then the default channel will not be created.
70 .PP
71 If one of the standard channels is set to NULL, either by calling
72 \fBTcl_SetStdChannel\fR with a NULL \fIchannel\fR argument, or by calling
73 \fBTcl_Close\fR on the channel, then the next call to \fBTcl_CreateChannel\fR
74 will automatically set the standard channel with the newly created channel. If
75 more than one standard channel is NULL, then the standard channels will be
76 assigned starting with standard input, followed by standard output, with
77 standard error being last.
78 .PP
79 See \fBTcl_StandardChannels\fR for a general treatise about standard
80 channels and the behavior of the Tcl library with regard to them.
81
82 .SH "SEE ALSO"
83 Tcl_Close(3), Tcl_CreateChannel(3), Tcl_Main(3), tclsh(1)
84
85 .SH KEYWORDS
86 standard channel, standard input, standard output, standard error