Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: bc9989396414269386c18c02c638260bf4418b771c21b50386fb53b018c2b834
Ticket: 2b6b0a57296aecf267d19554a6a0c6f2ac83efbc
writes accepted after non-blocking chan close write
User & Date: jan.nijtmans on 2026-11-20 16:41:51
Changes

  1. assignee changed to: "aku"
  2. closer changed to: "nobody"
  3. comment changed to:
    After <nowiki>[chan close $chan write]</nowiki> on a non-blocking channel with output still queued, the channel stays writable until the background flush finishes: <nowiki>[puts]</nowiki> is accepted and the data is sent after the half-close.
    
    <verbatim>
    set p [open |[list [info nameofexecutable] child.tcl] r+]   ;# child reads stdin later
    fconfigure $p -blocking 0
    puts -nonewline $p [string repeat a 1000000]
    chan close $p write      ;# returns at once, output still pending
    puts $p AFTER            ;# no error; the child receives "AFTER"
    </verbatim>
    
    A blocking channel gives "channel wasn't opened for writing". CloseWrite() sets CHANNEL_CLOSEDWRITE, but TCL_WRITABLE is reset only when the flush completes (CloseChannelPart), and neither Tcl_GetChannelMode() nor CheckChannelErrors() looks at CHANNEL_CLOSEDWRITE. Seen with pipes and sockets.
    
  4. icomment: "Merged to [a98d8d4e44|trunk]."
  5. login: "jan.nijtmans"
  6. mimetype: "text/x-fossil-wiki"
  7. resolution changed to: "Fixed"
  8. status changed to: "Pending"