mirror of
https://github.com/sheumann/hush.git
synced 2024-12-21 23:29:34 +00:00
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:
parent
b220322ac5
commit
ba87092078
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user