{"id":6697,"date":"2022-12-20T19:33:26","date_gmt":"2022-12-20T22:33:26","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/standard-channels-man3\/"},"modified":"2022-12-20T19:33:26","modified_gmt":"2022-12-20T22:33:26","slug":"standard-channels-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/standard-channels-man3\/","title":{"rendered":"Standard Channels (man3)"},"content":{"rendered":"<h1 align=\"center\">Standard Channels<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#INITIALIZATION OF TCL STANDARD CHANNELS\">INITIALIZATION OF TCL STANDARD CHANNELS<\/a><br \/> <a href=\"#RE-INITIALIZATION OF TCL STANDARD CHANNELS\">RE-INITIALIZATION OF TCL STANDARD CHANNELS<\/a><br \/> <a href=\"#SHELL-SPECIFIC DETAILS\">SHELL-SPECIFIC DETAILS<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#KEYWORDS\">KEYWORDS<\/a> <\/p>\n<hr>\n<p>______________________________________________________________________________<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Tcl_StandardChannels \u2212 How the Tcl library deals with the standard channels ______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This page explains the initialization and use of standard channels in the Tcl library.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The term <i>standard channels<\/i> comes out of the Unix world and refers to the three channels automatically opened by the OS for each new application. They are <b>stdin<\/b>, <b>stdout<\/b> and <b>stderr<\/b>. The first is the standard input an application can read from, the other two refer to writable channels, one for regular output and the other for error messages.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Tcl generalizes this concept in a cross-platform way and exposes standard channels to the script level.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>APPLICATION PROGRAMMING INTERFACES<\/b> <br \/> The public API procedures dealing directly with standard channels are <b>Tcl_GetStdChannel<\/b> and <b>Tcl_SetStdChannel<\/b>. Additional public APIs to consider are <b>Tcl_RegisterChannel<\/b>, <b>Tcl_CreateChannel<\/b> and <b>Tcl_GetChannel<\/b>.<\/p>\n<h2>INITIALIZATION OF TCL STANDARD CHANNELS <a name=\"INITIALIZATION OF TCL STANDARD CHANNELS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Standard channels are initialized by the Tcl library in three cases: when explicitly requested, when implicitly required before returning channel information, or when implicitly required during registration of a new channel.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">These cases differ in how they handle unavailable platform- specific standard channels. (A channel is not \u201cavailable\u201d if it could not be successfully opened; for example, in a Tcl application run as a Windows NT service.)<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"3%\">\n<p>1)<\/p>\n<\/td>\n<td width=\"8%\"><\/td>\n<td width=\"78%\">\n<p>A single standard channel is initialized when it is explicitly specified in a call to <b>Tcl_SetStdChannel<\/b>. The states of the other standard channels are unaffected.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:22%; margin-top: 1em\">Missing platform-specific standard channels do not matter here. This approach is not available at the script level.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\">2)<\/p>\n<\/td>\n<td width=\"8%\"><\/td>\n<td width=\"78%\">\n<p style=\"margin-top: 1em\">All uninitialized standard channels are initialized to platform-specific default values:<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:22%;\">(a)<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"4%\"><\/td>\n<td width=\"6%\"><\/td>\n<td width=\"68%\">\n<p style=\"margin-top: 1em\">when open channels are listed with <b>Tcl_GetChannelNames<\/b> (or the <b>file channels<\/b> script command), or<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"22%\"><\/td>\n<td width=\"4%\">\n<p>(b)<\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"68%\">\n<p>when information about any standard channel is requested with a call to <b>Tcl_GetStdChannel<\/b>, or with a call to <b>Tcl_GetChannel<\/b> which specifies one of the standard names (<b>stdin<\/b>, <b>stdout<\/b> and <b>stderr<\/b>).<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:22%; margin-top: 1em\">In case of missing platform-specific standard channels, the Tcl standard channels are considered as initialized and then immediately closed. This means that the first three Tcl channels then opened by the application are designated as the Tcl standard channels.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\">3)<\/p>\n<\/td>\n<td width=\"8%\"><\/td>\n<td width=\"78%\">\n<p style=\"margin-top: 1em\">All uninitialized standard channels are initialized to platform-specific default values when a user-requested channel is registered with <b>Tcl_RegisterChannel<\/b>.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">In case of unavailable platform-specific standard channels the channel whose creation caused the initialization of the Tcl standard channels is made a normal channel. The next three Tcl channels opened by the application are designated as the Tcl standard channels. In other words, of the first four Tcl channels opened by the application the second to fourth are designated as the Tcl standard channels.<\/p>\n<h2>RE-INITIALIZATION OF TCL STANDARD CHANNELS <a name=\"RE-INITIALIZATION OF TCL STANDARD CHANNELS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Once a Tcl standard channel is initialized through one of the methods above, closing this Tcl standard channel will cause the next call to <b>Tcl_CreateChannel<\/b> to make the new channel the new standard channel, too. If more than one Tcl standard channel was closed <b>Tcl_CreateChannel<\/b> will fill the empty slots in the order <b>stdin<\/b>, <b>stdout<\/b> and <b>stderr<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_CreateChannel<\/b> will not try to reinitialize an empty slot if that slot was not initialized before. It is this behavior which enables an application to employ method 1 of initialization, i.e. to create and designate their own Tcl standard channels.<\/p>\n<h2>SHELL-SPECIFIC DETAILS <a name=\"SHELL-SPECIFIC DETAILS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>tclsh<\/b> <br \/> The Tcl shell (or rather the function <b>Tcl_Main<\/b>, which forms the core of the shell\u2019s implementation) uses method 2 to initialize the standard channels.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>wish<\/b> <br \/> The windowing shell (or rather the function <b>Tk_MainEx<\/b>, which forms the core of the shell\u2019s implementation) uses method 1 to initialize the standard channels (See <b>Tk_InitConsoleChannels<\/b>) on non-Unix platforms. On Unix platforms, <b>Tk_MainEx<\/b> implicitly uses method 2 to initialize the standard channels.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Tcl_CreateChannel(3), Tcl_RegisterChannel(3), Tcl_GetChannel(3), Tcl_GetStdChannel(3), Tcl_SetStdChannel(3), Tk_InitConsoleChannels(3), tclsh(1), wish(1), Tcl_Main(3), Tk_MainEx(3)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">standard channels<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  Tcl_StandardChannels \u2212 How the Tcl library deals with the standard channels ______________________________________________________________________________ <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2536],"tags":[2538,3007,3075],"class_list":["post-6697","post","type-post","status-publish","format-standard","hentry","category-3-llamadas-de-bibliotecas","tag-2538","tag-man3","tag-tcl_standardchannels"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=6697"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6697\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}