Sync OpenBSD patchset 313:
Sync OpenBSD patchset 313:

Fix a race condition when asking a client to take over the terminal (switching
to a different poll loop):

If a MSG_READY was followed very quickly by a MSG_EXIT (for example if doing
"tmux new 'exit'"), both messages could be read as part of the same imsg_read
in the first client poll loop. The MSG_READY would then cause a switch to the
second client loop, which would immediately call poll(2) again, causing the
client to hang forever waiting for an exit message that it already had.

Change to call imsg_get to process any existing messages before polling.


klaxalk/tmux,klaxalk/tmux,klaxalk/tmux,klaxalk/tmux,klaxalk/tmux