Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 1a50187ea0a8252f043e3600ea63dc4aeb165f88
Ticket: 3059220fffffffffffffffffffffffffffffffff
On Windows non-blocking pipe does not flush
User & Date: apnadkarni on 2010-09-04 05:18:51
Changes

  1. assignee changed to: "andreas_kupries"
  2. cmimetype changed to: "text/plain"
  3. 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
    
    
  4. foundin changed to: "obsolete: 8.6b1.1"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "apnadkarni"
  10. subsystem changed to: "25. Channel System"
  11. title changed to: "On Windows non-blocking pipe does not flush"
  12. type changed to: "Bug"