Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Apr 1996 16:12:24 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        chuck@bus.net, joerg_wunsch@uriah.heep.sax.de
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: fbsd pty bug
Message-ID:  <199604120612.QAA31744@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>> > bytes were written!  Jove only checks whether the write was
>> > successful, and doesn't pay attention to the length reported by
>> > write.  Jove will not retry this write, although that would be
>> > reasonable.
>> 
>> I would consider this an error:
>> 
>> NAME
>>      write, writev - write output
>> ...
>>      When using non-blocking I/O on objects such as sockets that are subject
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>      to flow control, write() and writev() may write fewer bytes than request-
>>      ed; the return value must be noted, and the remainder of the operation
>>      should be retried when possible.
>> 
>> Now it's arguable whether a pty counts as ``subject to flow control'',
>> but a short write is IMHO not an exception.

A short write shouldn't happen for blocking I/O (O_NONBLOCK clear).

>> 
>> > 	Notice that the amount returned by the read was the length
>> > 	requested by bash.  I think that a pty should return at most a
>> > 	line at a time, even if the read requested more.
>> 
>> What does make you think this?  Tty's are not inherently line-bound,
>> so if there were more than a line available (regardles of your actual
>> problem with the multiple copies here), why should a read() only
>> return one line?

Because ICANON is set.  In that case, exactly one line is returned
(unless the read() buffer is too small to hold the line, when as much as
fits is returned).  Also, if the braindamaged limit MAX_INPUT is defined
in <limits.h> then it is guaranteed that the maximum line length is <=
MAX_INPUT, so readers should be able to guarantee reading exactly one
line by using a buffer size of MAX_INPUT.  FreeBSD defines MAX_INPUT
as 255, although the limit is currently 1024 and may change.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604120612.QAA31744>