| Ticket UUID: | 2b6b0a57296aecf267d19554a6a0c6f2ac83efbc | ||
| Title: | writes accepted after non-blocking chan close write | ||
| Type: | Bug | Created on: | 2026-10-16 21:22:15 |
| Submitter: | serhiy.storchaka | Assigned to: | jan.nijtmans |
| Subsystem: | 25. Channel System | Severity: | Minor |
| Priority: | 5 Medium | Last modified: | 2026-11-22 22:55:52 |
| Status: | Closed | Closed by: | jan.nijtmans |
| Resolution: | Fixed | Closed on: | 2026-11-22 22:55:52 |
| Version: | 8.6.18, 9.0.5, 9.1.0 | ||
| Description: | ||||
|
After [chan close $chan write] on a non-blocking channel with output still queued, the channel stays writable until the background flush finishes: [puts] is accepted and the data is sent after the half-close. 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" 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. | ||||
| User Comments: | ||||
serhiy.storchaka added on 2026-10-16 21:29:43:
Proposed fix in branch chan-close-write-pending: Tcl_GetChannelMode() does not report the write side once it is closed, so [puts] and a second [chan close $chan write] fail as for a blocking channel; the queued output is still flushed. Test iocmd-7.6. jan.nijtmans added on 2026-11-20 16:41:51:
Merged to [a98d8d4e44|trunk]. jan.nijtmans added on 2026-11-22 22:55:52:
Merged to [a98d8d4e44|trunk], core-9-0-branch and core-8-6-branch Many thanks! | ||||
