Work around problem where hush would hang after another process was ^C'd while reading from the terminal.

I think this problem is probably due to a bug in GNO's implementation of select().

The workaround is not to use poll (which calls select) when reading a key with no timeout (which is the normal case for command-line input).
This commit is contained in:
Stephen Heumann 2015-01-01 23:16:26 -06:00
parent b220322ac5
commit ba87092078

View File

@ -28,7 +28,18 @@ int32_t FAST_FUNC read_key(int fd, char *buffer, int timeout)
* If requested, wait TIMEOUT ms. TIMEOUT = -1 is useful
* if fd can be in non-blocking mode.
*/
if (timeout >= -1) {
/* On GNO, skip the poll if timeout == -1.
* It's pointless, since non-blocking mode isn't implemented,
* and it seems to hang in certain cases (e.g. where another
* process was interrupted while reading from the terminal).
* This may be due to bugs in the underlying select() implementation.
*/
#ifndef __GNO__
if (timeout >= -1)
#else
if (timeout >= 0)
#endif
{
if (safe_poll(&pfd, 1, timeout) == 0) {
/* Timed out */
errno = EAGAIN;