"Dr. David Alan Gilbert" <dgilb...@redhat.com> writes: > * Paolo Bonzini (pbonz...@redhat.com) wrote: >> >> >> On 29/03/2015 06:07, David Gibson wrote: >> > On Sat, Mar 28, 2015 at 04:30:06PM +0100, Paolo Bonzini wrote: >> >> >> >> >> >> On 25/02/2015 17:51, Dr. David Alan Gilbert (git) wrote: >> >>> + if (err != EAGAIN) { >> >> >> >> if (err != EAGAIN && err != EWOULDBLOCK) >> > >> > I assume that's for the benefit of non-Linux hosts? On Linux >> > EAGAIN == EWOULDBLOCK. >> >> Yes, that's just the standard idiom in QEMU. This is generic code, so >> assumption based on the host platform are not wise. :) > > Done; I didn't know of EWOULDBLOCK - and indeed as far as I can tell > most places we only test for EAGAIN.
Bug unless the place in question is effectively #ifdef __GNU_LIBRARY__ or similar. https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html#Error-Codes -- Macro: int EAGAIN Resource temporarily unavailable; the call might work if you try again later. The macro 'EWOULDBLOCK' is another name for 'EAGAIN'; they are always the same in the GNU C Library. This error can happen in a few different situations: * An operation that would block was attempted on an object that has non-blocking mode selected. Trying the same operation again will block until some external condition makes it possible to read, write, or connect (whatever the operation). You can use 'select' to find out when the operation will be possible; *note Waiting for I/O::. *Portability Note:* In many older Unix systems, this condition was indicated by 'EWOULDBLOCK', which was a distinct error code different from 'EAGAIN'. To make your program portable, you should check for both codes and treat them the same. * A temporary resource shortage made an operation impossible. 'fork' can return this error. It indicates that the shortage is expected to pass, so your program can try the call again later and it may succeed. It is probably a good idea to delay for a few seconds before trying it again, to allow time for other processes to release scarce resources. Such shortages are usually fairly serious and affect the whole system, so usually an interactive program should report the error to the user and return to its command loop. -- Macro: int EWOULDBLOCK In the GNU C Library, this is another name for 'EAGAIN' (above). The values are always the same, on every operating system. C libraries in many older Unix systems have 'EWOULDBLOCK' as a separate error code.