Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 4890c3ff0bb5653e55012a287b4e78bfd25855cb
Ticket: 465765ffffffffffffffffffffffffffffffffff
zero-length write considered harmful
User & Date: daletalcott on 2001-09-27 19:10:06
Changes

  1. assignee changed to: "vincentdarley"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Tcl 8.3.3, OS Platform AIX 4.3.3
    
    There is an unfortunate interaction between tcl and 
    Unix systems that implement the Single Unix 
    specification.  In particular, the Single Unix 
    specification for writing to/reading from a STREAM 
    device requires that a zero-length write on one 
    side show up as a zero-length read on the other.  
    That is, a zero-length write gets interpreted as EOF 
    when read.
    
    http://www.opengroup.org/onlinepubs/007908799/
    xsh/write.html
    http://www.opengroup.org/onlinepubs/007908799/
    xsh/read.html
    
    This is a problem for tcl because when tcl flushes 
    its channel buffers, if there is nothing in the buffer, 
    tcl ends up performing a zero-length write.  If the 
    channel happens to be connected to a STREAMS 
    file, this appears as EOF to the other side of the 
    STREAM.
    
    This causes grief for several programs, including 
    script, sshd, and expect.  It has the interesting 
    effect that, if you are logged on via SSH and run the 
    tcl test suite, you get logged off! during io.test.
    
    Fortunately, there are not that many OS's that 
    implement pseudo-tty's on STREAMS, but IBM's 
    AIX 4.3.3 is one.
    
    One can argue that the spec is wrong for changing 
    what used to be a harmless action (writing 
    nothing) into something that now has a meaning.  
    However, this is probably a losing battle.  I suggest 
    that tcl be modified to avoid zero-length writes.
    
    The following patch changes the Unix 
    FileOutputProc to avoid zero-length writes:
    
    --- unix/DRT/tclUnixChan.c      Tue Apr  3 17:54:39 
    2001
    +++ unix/tclUnixChan.c  Thu Sep 27 14:04:58 2001
    @@ -423,6 +423,8 @@
         int written;
     
         *errorCodePtr = 0;
    +    if (toWrite == 0)
    +       return 0;                       /* avoid zero-length write 
    */
         written = write(fsPtr->fd, buf, (size_t) toWrite);
         if (written > -1) {
             return written;
    
    This has been tested only to the extent that the tcl 
    tests now run on AIX without logging me off.
    
    
  4. foundin changed to: "obsolete: 8.3.3"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "daletalcott"
  9. subsystem changed to: "37. File System"
  10. title changed to: "zero-length write considered harmful"
  11. type changed to: "Bug"