]> git.ipfire.org Git - thirdparty/util-linux.git/commit
script: use empty-slave heuristic more carefully
authorKarel Zak <kzak@redhat.com>
Wed, 13 Apr 2016 09:52:43 +0000 (11:52 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 13 Apr 2016 09:52:43 +0000 (11:52 +0200)
commitb2bff0666101213d5ce9fc4166d8fc5b17581f57
tree0dde8d72216fc84bfea4b0fbaee04c186c06784b
parent44338f7fe6a529cef1f206dccd95e7282625c483
script: use empty-slave heuristic more carefully

script(1) waits for empty slave FD (shell stdin) before it writes to
master. This feature has been intorduiced by 54c6611d6f7b73609a5331f4d0bcf63c4af6429e
to avoid misbehavior when we need to send EOF to the shell.

Unfortunately, this feature has been used all time for all messages.
This is wrong because command in the session (or shell) may ignore
stdin at all and wait forever in busy loop is really bad idea. Test
case:

 script /dev/null
 tailf /etc/passwd
 <enter>
 <enter>

... script process taking 100% CPU.

This patch forces script to use empty-stave detection only when we
need to write EOF. The busy loop has been modified to use nanosleep
and it does not wait forever...

Addresses: http://bugs.debian.org/820843
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/script.c