Tarim <s...@mediaplaygrounds.co.uk> wrote:
>   Thanks Eric, that makes things a lot cleaner, more resilient and, at a
> guess, more portable (surely any OS with select will have O_NONBLOCK?)
 
O_NONBLOCK is common, yes, but I have zero knowledge or interest in
proprietary OSes.  For systems with O_NONBLOCK, the select calls in
kbhit are not even necessary anymore.  I didn't change kbhit to minimize
the patch size.

Did you get a chance to test and confirm my patch fixes things for you?

>   I agree it's more a performance bug but, I think, if select returns a
> spurious wakeup then the read should set EAGAIN (EWOULDBLOCK) - which
> the Linux 3.13.0-65.105-generic kernel doesn't.  (Not that this would
> have helped the unpatched sox).

read may only return EAGAIN when O_NONBLOCK is set; otherwise existing
applications which depend on blocking read will break.

Fwiw, blocking read can be a performance win in some cases: it can avoid
extra syscalls, avoid thundering herd, and improve fairness when
multiple threads/processes are reading a off the same pipe.

------------------------------------------------------------------------------
_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

Reply via email to