On Fri, Jun 28, 2024 at 11:36:20AM -0700, Jeremy wrote:
> On 06/28/24 10:52AM, Hiltjo Posthuma wrote:
> > Do you perhaps also have a way to easily reproduce this deadlock condition?
> 
> I cannot reproduce the deadlock on my machine. All I want to do is
> simplify ttywrite & I'm trusting that the author of 261ea4b has actually
> seen this problem before.
> 
> This is the comment from 261ea4b which I believe implies a deadlock
> when using st over serial:
> ...
>  * Remember that we are using a pty, which might be a modem line.
>  * Writing too much will clog the line. That's why we are doing this
>  * dance.
>  * FIXME: Migrate the world to Plan 9.
> ...

I've always interpreted it to mean that, since serial connections have
a constant transfer rate, and the OS buffers a finite number of bytes,
writing too many bytes to a serial device will make write(3) block,
which would make the terminal unresponsive until all the data is
transmitted by the hardware.

After that comment, in ttywriteraw():
        /*
         * We weren't able to write out everything.
         * This means the buffer is getting full
         * again. Empty it.
         */
        if (n < lim)
                lim = ttyread();

That makes sense, since reading N bytes will give the hardware enough
time to write at least N bytes.

I don't really understand why this use case needs to be handled at all.
Wouldn't you use something like minicom for a modem line?

-- 
Storkman

Reply via email to