]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lib/pty: Put master PTY into non-blocking mode and buffer its output to avoid deadlock
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Tue, 12 Apr 2022 14:25:14 +0000 (16:25 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 19 Apr 2022 09:55:52 +0000 (11:55 +0200)
commit2a6d17689cf4225a77e7d237a9e2ca8ead880d76
treec24ade4d7972a13244b7002c155f632ac7ed9b24
parent5a6c6dcde054ac7c246783b5f9843d86d2d9f053
lib/pty: Put master PTY into non-blocking mode and buffer its output to avoid deadlock

If we filled the script->child buffer before the child had a chance to read any
input, we'd sleep forever in write_all(pty->master), and the child would sleep
forever in write(1<pty->slave>)

By putting the master PTY in non-blocking mode, we can poll(pty->master,
POLLOUT) and keep supplying more data as the child reads from the buffer

Fixes Debian bug #1003095

Signed-off-by: Karel Zak <kzak@redhat.com>
include/pty-session.h
lib/pty-session.c