patch 8.0.1170: using termdebug results in 100% CPU time
Problem: Using termdebug results in 100% CPU time. (tomleb)
Solution: Use polling instead of select().
diff --git a/src/os_unix.c b/src/os_unix.c
index 3366efd..2a8e6ee 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -5330,6 +5330,9 @@
channel = add_channel();
if (channel == NULL)
goto failed;
+ if (job->jv_tty_out != NULL)
+ ch_log(channel, "using pty %s on fd %d",
+ job->jv_tty_out, pty_master_fd);
}
BLOCK_SIGNALS(&curset);
@@ -5702,6 +5705,9 @@
close(pty_master_fd);
return FAIL;
}
+ if (job->jv_tty_out != NULL)
+ ch_log(channel, "using pty %s on fd %d",
+ job->jv_tty_out, pty_master_fd);
job->jv_channel = channel; /* ch_refcount was set by add_channel() */
channel->ch_keep_open = TRUE;
@@ -5969,7 +5975,7 @@
}
# endif
#ifdef FEAT_JOB_CHANNEL
- nfd = channel_poll_setup(nfd, &fds);
+ nfd = channel_poll_setup(nfd, &fds, &towait);
#endif
if (interrupted != NULL)
*interrupted = FALSE;
@@ -6021,7 +6027,8 @@
}
# endif
#ifdef FEAT_JOB_CHANNEL
- if (ret > 0)
+ /* also call when ret == 0, we may be polling a keep-open channel */
+ if (ret >= 0)
ret = channel_poll_check(ret, &fds);
#endif
@@ -6097,7 +6104,7 @@
}
# endif
# ifdef FEAT_JOB_CHANNEL
- maxfd = channel_select_setup(maxfd, &rfds, &wfds);
+ maxfd = channel_select_setup(maxfd, &rfds, &wfds, &tv, &tvp);
# endif
if (interrupted != NULL)
*interrupted = FALSE;
@@ -6183,7 +6190,8 @@
}
# endif
#ifdef FEAT_JOB_CHANNEL
- if (ret > 0)
+ /* also call when ret == 0, we may be polling a keep-open channel */
+ if (ret >= 0)
ret = channel_select_check(ret, &rfds, &wfds);
#endif