]> git.ipfire.org Git - thirdparty/util-linux.git/commit
more: exit if POLLHUP or POLLERR on stdin is received
authorGoldwyn Rodrigues <rgoldwyn@suse.de>
Wed, 6 Dec 2023 19:19:17 +0000 (13:19 -0600)
committerKarel Zak <kzak@redhat.com>
Fri, 8 Dec 2023 11:44:48 +0000 (12:44 +0100)
commit9be4122b1d8c1c2b8eb270998838c73bae7ff2ff
treebc7ad8d4ee45c8b54ea8e16ce2f6fe3575f0ff12
parent75f9816a0a9d2a1cae555a44295b82b0412b6b5c
more: exit if POLLHUP or POLLERR on stdin is received

more command continues to run in case stdin have closed the file and it
takes 100% of CPU. This is because revents on stdin send
POLLIN | POLLHUP | POLLERR once stdin is closed. more receives it even
though it is not requested in events. This is common Linux behaviour to
never mask out POLLHUP or POLLERR. The loop in more_key_command() runs
infinitely because more_poll() returns 0 and read_command() reads 0
bytes.

Steps to reproduce:
1. Setup /etc/systemd/logind.conf with KillUserProcesses=no
2. Add config "Defaults use_pty" in /etc/sudoers
3. Start an ssh session to the machine
4. # sudo su -
5. # more <big enough file>
6. kill the parent ssh process, say close the tab

At this time "more" runs with 100% CPU utilization.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
text-utils/more.c