Skip to content
Tcl Source Code History Of Ticket 1873ea0ee4f01b26
Login

History Of Ticket 1873ea0ee4f01b26

Artifacts Associated With Ticket 1873ea0ee4f01b26

  1. Ticket change [c3d0c8c99b] (rid 161336) by sebres on 2018-03-05 13:46:23:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      I move here the ticket <a href="/thread/tktedit?name=c72c2eb54b644dc5e5b44b6a410311fca1b7a3ef">[c72c2eb54b]</a> posted to the thread-repository.
      
      As I understand, first calls of `open "nul" w`, on Windows within new thread, wrap the open channel to the std-channels.<br/>
      So second to fourth call (first time executed) get corresponding stdin, stdout and stderr.<br/>
      This occurs only within not console application, that does not share standard channels (currently reproducible for tk, not for tclsh).
      
      
      So as simplification it looks like:
      <code><pre>set t [thread::create]; 
      puts [join [thread::send $t { 
        set chs {}
        time { lappend chs [open nul w] } 5; 
        foreach ch $chs { close $ch }
        set chs
      }] \n]
      thread::release $t
      </pre></code>
      
      will give one the output:<code><pre>file11dd288
      stdin
      stdout
      stderr
      file11d03f0
      </pre></code>
      
      ---
      Original message from Timothy Tomkinson:<br/>
      ```
      
      In wish 8.6.8 on Windows, the 2nd, 3rd, and 4th files that are opened within a thread return the channel names stdin, stdout, and stderr. This does not happen in the main thread, in tclsh 8.6.8, in wish 8.5.*, or on Linux.
      
      For example, the following script writes the first 5 opened channel names to a log file:
      <code><pre>
          package require Thread
          set tid [::thread::create]
          ::thread::send $tid {
              set chan1 [open c:/temp/log.txt w]
              set chan2 [open nul w]
              set chan3 [open nul w]
              set chan4 [open nul w]
              set chan5 [open nul w]
              puts $chan1 "chan1 = $chan1"
              puts $chan1 "chan2 = $chan2"
              puts $chan1 "chan3 = $chan3"
              puts $chan1 "chan4 = $chan4"
              puts $chan1 "chan5 = $chan5"
              close $chan1
              close $chan2
              close $chan3
              close $chan4
              close $chan5
          }
          exit
      </pre></code>
      The file c:/temp/log.txt will contain something like:
      <code><pre>
          chan1 = file303b0c0
          chan2 = stdin
          chan3 = stdout
          chan4 = stderr
          chan5 = file3033160
      </pre></code>
      ```
      
    5. foundin initialized to: ">= 8.6"
    6. is_private initialized to: "0"
    7. login: "sebres"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "1c57e67924247fd7926e89348f266c081ec57db2"
    10. resolution initialized to: "None"
    11. severity initialized to: "Severe"
    12. status initialized to: "Open"
    13. submitter initialized to: "sebres"
    14. subsystem initialized to: "25. Channel System"
    15. title initialized to:
      open channel "nul" within non-main thread on windows (not-console application)
      
    16. type initialized to: "Bug"
  2. Ticket change [5f24443d5a] (rid 161337) by tomkiti on 2018-03-05 13:57:30:

    1. icomment:
      This happens when opening any file (including sockets), not just "nul".
      
    2. login: "tomkiti"
    3. mimetype: "text/html"
  3. Ticket change [784f5a2068] (rid 161338) by sebres on 2018-03-05 14:41:25:

    1. icomment:
      I got it now, this belongs to "wrong" recognition of first empty standart channel slots <a href="/tcl/artifact?name=af648152fc4ae2c1&ln=1742-1761">here</a>.
      
      This construction assumes that if (stdinInitialized = 1, etc), first 3 channels should get mapped to initial empty std-channels among the thread-storage.
      Which is rather actually wrong for the case of non-console application, or some initialization process does not set correctly stdinInitialized, stdoutInitialized etc in such case.
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
  4. Ticket change [ba7942e639] (rid 161339) by sebres on 2018-03-05 16:18:48:

    1. foundin changed to: ">= 8.5"
    2. icomment:
      The same in 8.5 (also mapped to stdin, stdout and stderr), excepting the channels get the names.
      
      This is because of the fully-correct commit [c0b94338ed879e40]:
      <pre><code style="color:green;">
      +	strcpy(tmp, "stdin");
      +	strcpy(tmp, "stdout");
      +	strcpy(tmp, "stderr");
      </code></pre>
      
      But the real cause is entirely different - this is TclpGetDefaultStdChannel with not allowed duplication for std-handle, returned with GetStdHandle, so returns NULL from the Tcl_MakeFileChannel...
      
      I'll fix it for all versions >= 8.5.
      
    3. login: "sebres"
    4. mimetype: "text/x-fossil-wiki"
  5. Ticket change [46b20943ca] (rid 161374) by sebres on 2018-03-05 17:50:35:

    1. closedate changed to: "2458183.24346959"
    2. closer changed to: "sebres"
    3. icomment:
      fixed for both versions now (8.5 [041bc74867] and >= 8.6 [6b38bf6d66]).
      
    4. login: "sebres"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"