mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Fix high CPU usage in subsequent select(2) calls
The timeout was being reset to zero, so `select` was being called in a very tight loop. Closes #5761.
This commit is contained in:
parent
49935f13df
commit
ab1519acef
1 changed files with 3 additions and 0 deletions
|
@ -76,6 +76,9 @@ void io_buffer_t::run_background_fillthread(autoclose_fd_t readfd) {
|
|||
FD_ZERO(&fds);
|
||||
FD_SET(fd, &fds);
|
||||
int ret = select(fd + 1, &fds, NULL, NULL, &tv);
|
||||
// select(2) is allowed to (and does) update `tv` to indicate how much time was left, so we
|
||||
// need to restore the desired value each time.
|
||||
tv.tv_usec = poll_timeout_usec;
|
||||
readable = ret > 0;
|
||||
if (ret < 0 && errno != EINTR) {
|
||||
// Surprising error.
|
||||
|
|
Loading…
Reference in a new issue