Skip to content
Tcl Source Code History Of Ticket 653218ffffffffff
Login

History Of Ticket 653218ffffffffff

Artifacts Associated With Ticket 653218ffffffffff

  1. Ticket change [4333706460] (rid 116514) by schroedter on 2002-12-13 11:54:58:

    1. assignee initialized to: "andreas_kupries"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized 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 initialized to: "obsolete: 8.4.1"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "schroedter"
    9. subsystem initialized to: "25. Channel System"
    10. title initialized to: "Channels CloseProc() not called on close"
    11. type initialized to: "Bug"
  2. Ticket change [46695c69c6] (rid 99514) by schroedter on 2002-12-13 18:58:29:

    1. icomment:
      Logged In: YES 
      user_id=99573
      
      This bahaviour may be interpretet not as a bug,
      but as a feature of the channel system.
      
      But then we need an additional option 
              [fconfigure $chan -flushonclose 0]
      (default=1) for channels like serial ports.
      
      
    2. login: "schroedter"
    3. mimetype: "text/plain"
    4. username: "schroedter"
  3. Ticket change [ecda7f38da] (rid 103778) by dkf on 2002-12-13 20:17:39:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      When I have time (maybe, just maybe, over Xmas) I'll be
      advancing a TIP on behaviour-on-close of serial channels.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  4. Ticket change [65cb6e2bfc] (rid 102605) by dgp on 2002-12-13 20:51:55:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      Is this related to FR 525783 ?
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  5. Ticket change [b0d95fe8d8] (rid 98050) by schroedter on 2002-12-13 21:14:31:

    1. icomment:
      Logged In: YES 
      user_id=99573
      
      IMO not. [ 526163 ] tty not reset on exit 
      is related to the (requested) change made by TIP#35, not to
      restore the original TTY settings on close, so that tcl can
      be used as a simple 
      'stty' substitute.
      This stuff is not yet finally removed - see the comment in
      tclUnixChan.c, ttyCloseProc().
      
      
      
      
    2. login: "schroedter"
    3. mimetype: "text/plain"
    4. username: "schroedter"
  6. Ticket change [fd94c4c9e8] (rid 108427) by andreas_kupries on 2003-01-07 05:52:45:

    1. icomment:
      Logged In: YES 
      user_id=75003
      
      Note: If BG_FLUSH_SCHEDULED is set the channel cannot 
      be closed completely. There is a BackGround-FLUSH of data 
      active. The channel won't be visible at the script level 
      anymore, but the data structures remain until the flush is 
      completed. After that happend the close proc is called and 
      the structures are cleaned up completely. This is only for a 
      non-blocking channel.
      
      To get 'flushonclose' behaviour just set the channel to -
      blocking 1. Of course, this may stall the [close] at the tcl 
      level if the serial port itself is stalled.
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  7. Ticket change [1ab2d5312b] (rid 123024) by schroedter on 2003-01-07 15:28:10:

    1. icomment:
      Logged In: YES 
      user_id=99573
      
      Yes, what you say emphasizes that Tcl needs a mechanism  
      to close a stalled serial channel by discarding all currently 
      pending output.
      
      
    2. login: "schroedter"
    3. mimetype: "text/plain"
    4. username: "schroedter"
  8. Ticket change [b7d2e6fea8] (rid 128861) by dkf on 2003-01-07 17:59:04:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      There are several possible desired behaviours for what
      should happen on closing of a serial channel, but I think
      these are the interesting cases:
        wait until all OS buffers are empty and reset to initial
      state
        discard all pending output (including OS level) and reset
      to init.
        leave channel in *current* state
      (I'll not specify what happens to the OS buffers in that
      last case as I believe that typically in that case, there
      won't be much data in the buffers anyway!)
      
      IIRC, right now we just support the first of those, and we
      know that selection of the right behaviour can't be done
      automatically (we don't want to discard debug info!) so that
      calls for a suitable [fconfigure] option. Which means a TIP.
      Which I've not had time to write.  (And I'm not certain how
      -blocking interacts with this; the buffers in question are
      in the OS, not Tcl.)
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  9. Ticket change [643fb62ba9] (rid 92725) by schroedter on 2003-01-08 13:52:51:

    1. icomment:
      Logged In: YES 
      user_id=99573
      
      For blocking channels no changes are necessary.
      For non-blocking channels the current behaviour is to put the 
      channel to *blocking* mode, wait until all Tcl output buffers 
      are done and only then call Tcl_DriverCloseProc(). 
      
      If there would be a non-default [fconfigure -discardonclose 1] 
      option the channel system should
      1. *Not* make the channel blocking.
      2. Discard all pending output in Tcl buffers.
      3. Immediately call Tcl_DriverCloseProc().
      
      The serial SerialCloseProc() is responsive for the OS-level 
      output. So SerialCloseProc() should also check for the 
      [fconfigure -discardonclose 1] flag and discard OS-level output.
      
      I could write the TIP and implement the the changes in the 
      serial drivers SerialCloseProc() for Windows & Posix. But I do 
      not feel skilled for the changes in the general channel system.
      
      
      
    2. login: "schroedter"
    3. mimetype: "text/plain"
    4. username: "schroedter"
  10. Ticket change [6753ec15a4] (rid 102880) by dkf on 2003-10-16 20:59:24:

    1. resolution changed to: "Remind"
  11. Ticket change [005ad727f2] (rid 258324) by serhiy.storchaka on 2026-10-16 21:49:57:

    1. icomment:
      The deferred close is by design (see close(n)). Testing this found that on Linux in 8.7 and later a background flush to a pipe whose reader has exited never ends: [7aa8fd34c4].
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
    4. resolution changed to: "Invalid"
    5. status changed to: "Closed"
  12. Ticket change [20bd9150f8] (rid 259953) by serhiy.storchaka on 2026-10-22 17:19:27:

    1. closedate changed to: "2461330.4096968286"
    2. closer changed to: "serhiy.storchaka"
    3. login: "serhiy.storchaka"