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:
@@ -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 */
|
||||
|
Reference in New Issue
Block a user