2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 01:49:11 +00:00

Fix non-blocking mode. We only want to exit the event loop when

poll() or select() returns 0 and there are no active events.  This
fixes a problem on some systems where the last buffer was not being
written when the command exited.
This commit is contained in:
Todd C. Miller 2014-05-02 14:57:36 -06:00
parent a53946b026
commit 4e333c5165

View File

@ -286,6 +286,11 @@ rescan:
TAILQ_INSERT_TAIL(&base->active, ev, active_entries);
SET(ev->flags, SUDO_EVQ_ACTIVE);
}
if (ISSET(flags, SUDO_EVLOOP_NONBLOCK)) {
/* If nonblocking, return immediately if no active events. */
if (TAILQ_EMPTY(&base->active))
goto done;
}
break;
default:
/* I/O events active, sudo_ev_scan_impl() already added them. */
@ -333,7 +338,7 @@ rescan:
SET(base->flags, SUDO_EVBASE_GOT_EXIT);
goto done;
}
if (flags & (SUDO_EVLOOP_ONCE | SUDO_EVLOOP_NONBLOCK))
if (ISSET(flags, SUDO_EVLOOP_ONCE))
break;
}
done: