]> git.ipfire.org Git - thirdparty/util-linux.git/commit
more: exit if POLLERR and POLLHUP on stdin is received
authorGoldwyn Rodrigues <rgoldwyn@suse.com>
Fri, 8 Dec 2023 15:04:39 +0000 (09:04 -0600)
committerGoldwyn Rodrigues <rgoldwyn@suse.com>
Fri, 8 Dec 2023 15:54:12 +0000 (09:54 -0600)
commit68e14d3d5f4116ad3aca0e392d008645ea90cf70
treed62dbc866e27191d34ba551a1ff70997548f52b9
parent6b081fa421f4028bad0be22178f8d8e5e9015041
more: exit if POLLERR and POLLHUP 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.

Check for POLLERR and POLLHUP, and exit more in case of an error.

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