Resource Temporarily Unavailable workaround

Andrew STUBBS andrew.stubbs@st.com
Thu Nov 22 16:42:00 GMT 2007


Hi all,

I have recently been plagued by the 'Cannot fork: Resource temporarily 
unavailable' problem.

Searching the web reveals the there are about half as many solutions as 
there are people complaining about it, none of which work for me (or the 
other half of the complaining people, apparently).

If I'm wrong about this then stop me now, and tell me how I should have 
fixed it. :)

Anyway, here's *my* solution, and hopefully this one can be made to work 
for other people also.

The attached patch adds a 'retry' to the fork system call. Basically it 
waits 10 seconds to allow the 'resource temporarily unavailable' to 
become (temporarily) available once more, and tries again, up to a 
maximum of three attempts.

It also saves a log file (under /tmp) so that I can see whether it is 
doing anything or not - the problem is impossible to reproduce at will. 
This is merely a debugging aid and should be removed from the final 
patch. I did a complete build of our product and the log file indicates 
the problem was averted twice. On both occasions a single retry was 
sufficient.

I do not claim that this patch is in any way ready to commit. It is 
merely a proof of concept.

I do not know what the requirements are for submission of patches to 
this project. If I require any sort of copyright assignment then please 
feel free to use my idea, but I shall not be able to help with the final 
implementation.

I hope we can find some acceptable way of solving this nasty problem.

Andrew Stubbs
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygwin-fork.patch
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20071122/697fd6c6/attachment.ksh>


More information about the Cygwin-patches mailing list