in reply to Expect and PTY dropping data

After some investigation I have found that the operative system drops data when syswrite is called with more than 512 bytes or when consecutive enough syswrites summing up more than 512 bytes are performed.
syswrite returns the number of bytes written, and the caller is responsible for re-syswriting the bytes that didn't get written. Is it possible that the return value is not being checked? Or is the OS simply reporting that the syswrite call succeeded even though data is being dropped?

Replies are listed 'Best First'.
Re^2: Expect and PTY dropping data
by salva (Canon) on May 21, 2008 at 14:56 UTC
    At the Perl level, syswrite reports that all the data has been written. At the OS level, a process monitoring tool such as truss shows the write call also reporting that all the data has been written.

    And BTW, the dropped data is not the chunk tail but the head!

    update: this is the interaction between both processes at the OS level:

    27168: write(4, "\0\0\00501\0\0\003", 9) = 9 27170: read(7, "\0\0\00501\0\0\003", 16384) = 9 27170: write(8, "\0\0\00502\0\0\003", 9) = 9 27168: read(4, "\0\0\00502\0\0\003", 16384) = 9 27168: write(4, "\0\0\0" 03\0\0\0\0\0\0\0\r/ t m ".., 38) = 38 27170: read(7, "\0\0\0" 03\0\0\0\0\0\0\0\r/ t m ".., 16384) = 38 27170: write(8, "\0\0\0\rf \0\0\0\0\0\0\004\0\0\0".., 17) = 17 27168: read(4, "\0\0\0\rf \0\0\0\0\0\0\004\0\0\0".., 16384) = 17 27168: write(4, "\0\0\015\n\0\0\001\0\0\004\0\0\0".., 25) = 25 27170: read(7, "\0\0\015\n\0\0\001\0\0\004\0\0\0".., 16384) = 25 27170: write(8, "\0\0\018e \0\0\001\0\0\0\0\0\0\0".., 28) = 28 27168: read(4, "\0\0\018e \0\0\001\0\0\0\0\0\0\0".., 16384) = 28 27168: write(4, "\0\0@ 1906\0\0\002\0\0\004\0\0\0".., 16413) = 16413 27170: read(7, "a l / l i b \nL I B C = \nL ".., 16384) = 1024
    Note how reads and writes for both processes interleave until the last one where only 1024 bytes are read by the child and that those bytes do not correspond to the head of the last write operation performed on the parent!
      This sounds like an operating system bug.

      If it is indeed, you shouldn't even think about fixing it on the perl level. Write a bug report against the OS instead.