Re: Realloc is blocking execution
On Tue, 13 Oct 2009, Felipe Sateler wrote:
I've always assumed that malloc (and thus realloc) can sleep.
I believe the creators of the Single UNIX Specification didn't share (or
at least, didn't codify) this assumption. As a general rule, any system
interface that is designed to wait (= hang indefinitely) on a resource
- can be either used in some non-blocking way when it returns EAGAIN,
- or it can be interrupted by a signal, when it returns -1 and sets errno
- or you can specify a time limit,
- or it is a thread cancellation point.
In short, if a system interface goes to sleep by design, it can be woken
up in a way or another, or else the system interface description
explicitly says it cannot be woken up. The malloc() description under 
makes me think that malloc() cannot hang indefinitely by design.