Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Channel Names Incorrect in Threads

Closed / Wont Fix2928272fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 16 years ago
Descriptionplain2010-01-08 13:46:26
In wish for Windows, the output of [chan names] is incorrect in threads. The following script demonstrates this:

    package require Thread
    set tid [thread::create]
    puts [thread::send $tid {chan names}]
    puts [thread::send $tid {open ~/temp.txt w}]
    puts [thread::send $tid {chan names}]

In tclsh and wish for Unix, the correct output is:

    stderr stdout stdin
    filee5cd20
    stderr stdout stdin filee5cd20

In wish for Windows, the incorrect output is:

    <blank>
    fileecff28
    stdin

The first call returns an empty string, which is well-documented in Brent Welch's book. The second call returns "stdin" instead of the new channel. Subsequent calls to "open" will produce "stdout" and "stderr" to appear, although they don't really exist.
dgpplain2010-01-08 22:14:03
More fallout from 2849797 I think.
nijtmansplain2010-01-09 00:05:00
>More fallout from 2849797 I think

I don't think so: This bug is reported against
8.5.8, and #2849797 is only in 8.6!

Therefore, I don't think that the priority
should be that high.   ;-)
tomkitiplain2010-01-09 04:39:21
I just tried 8.6.0.0b2 and the same thing occurs.
hobbsplain2010-08-05 02:55:01
This is quasi- (poorly?) documented behavior.  If you see the docs for Tcl_OpenFileChannel (http://www.tcl.tk/man/tcl8.5/TclLib/OpenFileChnl.htm#M6) it actually allows inheritance of the std channels when they don't exist.

I've always thought this was a bad behavior, but it was taken from libc behavior.
jenglishplain2010-08-05 07:29:20
>I've always thought this was a bad behavior,
{ agreed }
> but it was taken from libc behavior.

... and for the record, it was taken *incorrectly*; Tcl's treatment of closed std* channels was based on an apparent misunderstanding.

In C,  fclose(stdin);  followed by a successfull call to fopen("whatever","r");  does *not* magically resurrect the stdin FILE *, and never has.
sf-robotplain2010-09-30 02:00:04
allow_comments - 1

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).
Log in (anonymous is fine) to add a comment.