2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-05 00:35:14 +00:00

When waiting for the parent to grant us the tty, use nanosleep

instead of spinning to avoid hogging the CPU.
This commit is contained in:
Todd C. Miller
2017-01-12 10:44:26 -07:00
parent 0ef26ff0b7
commit 2f0295373a
9 changed files with 152 additions and 5 deletions

View File

@@ -1556,8 +1556,9 @@ exec_pty(struct command_details *details,
/* Wait for parent to grant us the tty if we are foreground. */
if (foreground && !ISSET(details->flags, CD_EXEC_BG)) {
struct timespec ts = { 0, 1000 }; /* 1us */
while (tcgetpgrp(io_fds[SFD_SLAVE]) != self)
continue; /* spin */
nanosleep(&ts, NULL);
}
/* We have guaranteed that the slave fd is > 2 */