Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 59220a6fac2d9c9d2fe85870b8bf45a0bc1f36f7
Ticket: 3059220fffffffffffffffffffffffffffffffff
On Windows non-blocking pipe does not flush
User & Date: apnadkarni on 2014-08-02 09:13:16
Changes

  1. assignee changed to: "aku"
  2. closedate changed to: "2456871.88421294"
  3. closer changed to: "apnadkarni"
  4. comment changed to:
    After writing consecutive newlines on a line buffered non-blocking channel pipe to a child process, the parent tclsh process seems to stop flushing further writes unless event loop is run. 
    
    Windows XP, both 8.6 CVS head and 8.5.8
    See sample session:
    
    % set fd [open {| ./tclsh85.exe} r+]
    file9cfd08
    % fconfigure $fd -buffering line -blocking 0
    % puts $fd {puts foo}   ;# Ask child process to echo foo
    % gets $fd                 ; # Read back response
    foo
    % puts $fd {puts foo}  ; # Once more just to verify
    % gets $fd
    foo
    % puts $fd {
    }
    % gets $fd   ; # Fine, non-blocking, empty string returned as child was not asked to send back a response
    % puts $fd {puts foo}  ; # Now retry previous command
    % gets $fd                ; # Unlike before, no response, expected "foo" as before
    % flush $fd               ; # SHould not be necessary, but just in case
    % gets $fd               ; # flush no use
    % update                 ; # Run event loop
    % gets $fd               ; Ah now channel gets flushed, and child returns response
    foo
    
    Not clear if above is a bug, or my understanding (that non-blocking I/O does not need the event loop if filevents are not being used) is incorrect. I don't see why the behaviour in echoing "foo" changes after writing the empty line
    Tracing indicates the following:
    - the data is not being flushed from the parent process output buffer
    - exiting the parent before the update results in all pending data being flushed (as expected). The child then sees that data (not shown above, but verified through logging)
    - Removing the -buffering line gets rid of the issue, at least for this particular sequence
    - if instead of writing puts {
    } you write puts "" on consecutive command lines, the problem does not show.
    
    /Ashok
    
  5. icomment:
    Closed my bug because fconfigure documentation states clearly (at least in the current version) that the event loop is required for non-blocking i/o to flush.
    
  6. login: "apnadkarni"
  7. mimetype: "text/plain"
  8. severity changed to: "Minor"
  9. status changed to: "Closed"