Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/GetStdChan.3 @ 43

Last change on this file since 43 was 25, checked in by landauf, 16 years ago

added tcl to libs

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