GetStdChan.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:4k
- '"
- '" Copyright (c) 1996 by Sun Microsystems, Inc.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" RCS: @(#) $Id: GetStdChan.3,v 1.4.4.1 2006/06/06 20:07:36 dgp Exp $
- '"
- .so man.macros
- .TH Tcl_GetStdChannel 3 7.5 Tcl "Tcl Library Procedures"
- .BS
- '" Note: do not modify the .SH NAME line immediately below!
- .SH NAME
- Tcl_GetStdChannel, Tcl_SetStdChannel - procedures for retrieving and replacing the standard channels
- .SH SYNOPSIS
- .nf
- fB#include <tcl.h>fR
- .sp
- Tcl_Channel
- fBTcl_GetStdChannelfR(fItypefR)
- .sp
- fBTcl_SetStdChannelfR(fIchannel, typefR)
- .sp
- .SH ARGUMENTS
- .AS Tcl_Channel channel in
- .AP int type in
- The identifier for the standard channel to retrieve or modify. Must be one of
- fBTCL_STDINfR, fBTCL_STDOUTfR, or fBTCL_STDERRfR.
- .AP Tcl_Channel channel in
- The channel to use as the new value for the specified standard channel.
- .BE
- .SH DESCRIPTION
- .PP
- Tcl defines three special channels that are used by various I/O related
- commands if no other channels are specified. The standard input channel
- has a channel name of fBstdinfR and is used by fBreadfR and fBgetsfR.
- The standard output channel is named fBstdoutfR and is used by
- fBputsfR. The standard error channel is named fBstderrfR and is used for
- reporting errors. In addition, the standard channels are inherited by any
- child processes created using fBexecfR or fBopenfR in the absence of any
- other redirections.
- .PP
- The standard channels are actually aliases for other normal channels. The
- current channel associated with a standard channel can be retrieved by calling
- fBTcl_GetStdChannelfR with one of
- fBTCL_STDINfR, fBTCL_STDOUTfR, or fBTCL_STDERRfR as the fItypefR. The
- return value will be a valid channel, or NULL.
- .PP
- A new channel can be set for the standard channel specified by fItypefR
- by calling fBTcl_SetStdChannelfR with a new channel or NULL in the
- fIchannelfR argument. If the specified channel is closed by a later call to
- fBTcl_ClosefR, then the corresponding standard channel will automatically be
- set to NULL.
- .PP
- If a non-NULL value for fIchannelfR is passed to fBTcl_SetStdChannelfR,
- then that same value should be passed to fBTcl_RegisterChannelfR, like so:
- .CS
- Tcl_RegisterChannel(NULL, channel);
- .CE
- This is a workaround for a misfeature in fBTcl_SetStdChannelfR that it
- fails to do some reference counting housekeeping. This misfeature cannot
- be corrected without contradicting the assumptions of some existing
- code that calls fBTcl_SetStdChannelfR.
- .PP
- If fBTcl_GetStdChannelfR is called before fBTcl_SetStdChannelfR, Tcl will
- construct a new channel to wrap the appropriate platform-specific standard
- file handle. If fBTcl_SetStdChannelfR is called before
- fBTcl_GetStdChannelfR, then the default channel will not be created.
- .PP
- If one of the standard channels is set to NULL, either by calling
- fBTcl_SetStdChannelfR with a NULL fIchannelfR argument, or by calling
- fBTcl_ClosefR on the channel, then the next call to fBTcl_CreateChannelfR
- will automatically set the standard channel with the newly created channel. If
- more than one standard channel is NULL, then the standard channels will be
- assigned starting with standard input, followed by standard output, with
- standard error being last.
- .PP
- See fBTcl_StandardChannelsfR for a general treatise about standard
- channels and the behaviour of the Tcl library with regard to them.
- .PP
- .SH "SEE ALSO"
- Tcl_Close(3), Tcl_CreateChannel(3), Tcl_Main(3), tclsh(1)
- .SH KEYWORDS
- standard channel, standard input, standard output, standard error