Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d229dd74bf5493e1d1cade14cc8e2609d63fbeb3
Ticket: 2407783fffffffffffffffffffffffffffffffff
Seek causes IO channel to be shared between all interps
User & Date: sbron on 2008-12-08 22:44:14
Changes

  1. assignee changed to: "hobbs"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    I noticed that 'seek 0' on a file handle makes the handle accessible in all interps. I can't find any evidence in the docs that this is the intended behavior.
    
    Example: The following script will dump 2 x four bytes from /dev/random:
    
    interp create foo
    interp create bar
    
    set f [open /dev/random rb]
    
    interp eval foo {
        proc bytes {fh} {
            binary scan [read $fh 4] H* hex
            puts $hex
            close $fh
        }
    }
    
    interp eval bar {
        proc bytes {fh} {
            binary scan [read $fh 4] H* hex
            puts $hex
            close $fh
        }
    }
    
    seek $f 0
    interp eval foo [list bytes $f]
    interp eval bar [list bytes $f]
    close $f
    
    Without the seek command it reports an error as expected:
    can not find channel named "file5"
        while executing
    "read $fh 4"
        (procedure "bytes" line 2)
        invoked from within
    "bytes file5"
        invoked from within
    "interp eval foo [list byte $f]"
    
    
    SuSE linux 11.0
    Kernel 2.6.25.18-0.2-pae
    Tcl 8.5.5
    
    
  4. foundin changed to: "obsolete: 8.5.5"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "sbron"
  10. subsystem changed to: "20. [interp]"
  11. title changed to:
    Seek causes IO channel to be shared between all interps
    
  12. type changed to: "Bug"