basic/terminal-util: add check for poll timeout in get_default_background_color

Currently the return value 0 is not checked for, this indicates a
timeout and should be handled to prevent doing a blocking read on a file
descriptor with no data ready.
This commit is contained in:
Sam Leonard 2024-02-27 11:12:39 +00:00
parent 39af486a7f
commit 9924d3c595
No known key found for this signature in database
GPG key ID: 96850F0978CE78F0

View file

@ -1744,6 +1744,10 @@ int get_default_background_color(double *ret_red, double *ret_green, double *ret
r = fd_wait_for_event(STDIN_FILENO, POLLIN, usec_sub_unsigned(end, n));
if (r < 0)
goto finish;
if (r == 0) {
r = -EOPNOTSUPP;
goto finish;
}
ssize_t l;
l = read(STDIN_FILENO, buf, sizeof(buf) - buf_full);