[PATCH] prevent retries on fclose/fflush after write errors

Rich Felker dalias at aerifal.cx
Tue Mar 13 15:04:04 UTC 2012

On Tue, Mar 13, 2012 at 01:46:39AM -0400, Mike Frysinger wrote:
> treating EINTR/EAGAIN as unrecoverable is bad behavior for an app.  there are 
> valid ways an app could receive either signal and have it be normal behavior.

Receiving a signal does not result in EINTR. Running a signal handler
that was installed (intentionally) without SA_RESTART is what causes

> having that handling be done in uClibc is not required by POSIX, but it's 
> better imo for uClibc to carry a little bit more code there to provide better 
> reliability to higher layers rather than forcing every userspace app to 
> implement their own retry-on-eagain macros.

Retrying on EAGAIN is simply *wrong*. It makes you consume 100% cpu.
If the file descriptor is set as EAGAIN, it means whoever set it up
wants to ensure that blocking does not happen; emulating blocking with
100% cpu load is the worst possible way to handle this situation! For
stdio, EAGAIN must be treated as a hard error.


More information about the uClibc mailing list