When resources run out... There are various types of resources allocated by the operating system, such as semaphores, file descriptors, process entries and memory, that may run out temporarily. Always check if a resource allocation operation failed. If an allocation operation fails and this might be a temporary situation, wait a bit (sleep()?), and try again. After a given set of retries - give up. If you plan to use a lot of resources of a given type (e.g. file descriptors) - consider implementing some caching mechanism to save resources.