Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 43337064607a25e7f1a6a77cc394c3f6ca37a909
Ticket: 653218ffffffffffffffffffffffffffffffffff
Channels CloseProc() not called on close
User & Date: schroedter on 2002-12-13 11:54:58
Changes

  1. assignee changed to: "andreas_kupries"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    
    If there is pending BG output for a non-blocking channel 
    then Tcl_DriverCloseProc() is not called when the 'close' 
    command is invoked.
    
    That can be seen from generic/tclIO.c : 
    Tcl_Unregister_Channel():
        if (!(statePtr->flags & BG_FLUSH_SCHEDULED)) {
            ...
    
    This can be very bad if channel's output is stalled, e.g. a 
    serial port blocked by handshake:
    
    % puts "Tcl $tcl_patchLevel"
    Tcl 8.4b1
    % set chan [open com1: r+]
    fileaaf550
    % fconfigure $chan -buffering none -blocking 0
    % fconfigure $chan -mode 1200,n,8,1 -handshake rtscts
    % ### 2 outputs: "hello world" \x0D\x0A, BG_FLUSH
    % puts $chan "hello world"
    % puts "Queue: [fconfigure $chan -queue]"
    Queue: 0 13
    % after 1000
    % puts "Queue: [fconfigure $chan -queue]"
    Queue: 0 13
    % close $chan
    % set chan [open com1: r+]
    couldn't open "com1:": permission denied
    % 
    
    This problem occurs also for slow output without 
    handshake:
    
    % puts "Tcl $tcl_patchLevel"
    Tcl 8.4b1
    % set chan [open com1: r+]
    fileaaf768
    % fconfigure $chan -buffering none -blocking 0
    % # Explicitely reset handshake=none
    % fconfigure $chan -mode 1200,n,8,1 -handshake none
    % puts $chan "hello world"
    % puts $chan "hello world"
    % close $chan
    % set chan [open com1: r+]
    couldn't open "com1:": permission denied
    
    
    For Tcl < 8.4. this has never been observed for serial 
    ports, because serial output has already been blocking.
    
    
  4. foundin changed to: "obsolete: 8.4.1"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "schroedter"
  9. subsystem changed to: "25. Channel System"
  10. title changed to: "Channels CloseProc() not called on close"
  11. type changed to: "Bug"