]> 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>
Fri, 15 Apr 2016 14:26:51 +0000 (16:26 +0200)
commit0f2f9fbd886a6418e6475b3c895b7da03462421c
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