Overview
| Artifact ID: | 4890c3ff0bb5653e55012a287b4e78bfd25855cb |
|---|---|
| Ticket: | 465765ffffffffffffffffffffffffffffffffff
zero-length write considered harmful |
| User & Date: | daletalcott on 2001-09-27 19:10:06 |
Changes
- assignee changed to: "vincentdarley"
- cmimetype changed to: "text/plain"
- 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. - foundin changed to: "obsolete: 8.3.3"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "daletalcott"
- subsystem changed to: "37. File System"
- title changed to: "zero-length write considered harmful"
- type changed to: "Bug"