From: Eric Wong <e...@80x24.org> When accepting keyboard input, it is possible for select() to return a false-positive with spurious wakeups from inside the update_status callback.
Using the FIONREAD ioctl in place of select is also a possibility, but may be less portable. --- src/sox.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/sox.c b/src/sox.c index 9412614e..6b35041b 100644 --- a/src/sox.c +++ b/src/sox.c @@ -1804,6 +1804,18 @@ static int process(void) tcsetattr(fileno(stdin), TCSANOW, &modified_termios); } #endif +#if defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK) + if (interactive) { + int fd = fileno(stdin); + int flags = fcntl(fd, F_GETFL); + if (flags == -1) { + lsx_warn("error getting flags on stdin descriptor: %s", strerror(errno)); + } else if (!(flags & O_NONBLOCK)) { + if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) + lsx_warn("error setting non-blocking on stdin: %s", strerror(errno)); + } + } +#endif setsig(SIGTERM, sigint); /* Stop gracefully, as soon as we possibly can. */ setsig(SIGINT , sigint); /* Either skip current input or behave as SIGTERM. */ _______________________________________________ SoX-devel mailing list SoX-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sox-devel