Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

zpty -w silently truncates nonblocking writes with status 0



With a PTY created using zpty -b, writing a large string can return status 0 after delivering only a prefix. The remainder is discarded, and no byte count is exposed for retrying.

repro:
https://github.com/klntsky/zpty-partial-write-repro/

It sends 200000 bytes to a raw mode PTY whose reader briefly delays. only 11776 bytes get received

ptywritestr() returns success on EAGAIN after any bytes have been written:
https://github.com/zsh-users/zsh/blob/zsh-5.9/Src/Modules/zpty.c#L714

Current master has this logic. The manual warns about incomplete stdin copying, but not successful truncation of string arguments.

Is this intended, and should callers use syswrite -c with explicit buffering for reliable nonblocking delivery? If so, could that limitation be documented?


Messages sorted by: Reverse Date, Date, Thread, Author