fork: Resource temporarily unavailable

I'm running into a problem where I get a "fork: Resource temporarily unavailable" when attempting to run new processes in terminal.

I've traced it down to system set process limits. I found this ( http://hints.macworld.com/article.php?story=200311151254441) which explains how to increase the process limits (unfortunately written for osx 10.3), but that hasn't helped.

Currently, I've added the following lines to /etc/sysctl.conf


kern.maxproc=2048
kern.maxprocperuid=512




But it didn't help. The page mentioned above also suggested moving WindowServer aside and instead setting up a shell script that first ran "ulimit -u 512", then the original WindowServer binary. While I did make the script executable, this rendered my laptop unbootable (in so far as the login window would never come up. I booted of the system cd and replaced the script with the original WindowServer binary). I looked through the console log and found this error:

The following job tried to hijack the service "com.apple.windowserver" from this job: 0x10011f6d0.anonymous.WindowServer.ori

(I had renamed the original binary to WindowServer.original, which I assume is what's causing the .ori)


Now, I can add a 'ulimit -u 512' to my bashrc which will solve the problem for terminal windows that open before hitting 266 processes, but if I try to open a new terminal window, it will fail.

Any idea how I can raise the per-user process limit for the entire machine?

MacbookPro 2.4ghz i5, 8gb, Mac OS X (10.6.6)

Posted on Feb 16, 2011 5:35 PM

Reply
2 replies

Feb 17, 2011 6:25 AM in response to fjenkins

What about /etc/launchd.conf

Some google searches on launchd.conf seem to indicate you can issue some commands at boot time via launchd.conf. Maybe you can issue

sysctl -w kern.maxproc=2048
sysctl -w kern.maxprocperuid=512

within /etc/launchd.conf

I am just guessing here. I did some googling and found some references to setting environment variables at boot time, so if you can issues export commands, maybe you can also issue sysctl commands.

Your mileage may vary. Objects are closer than they appear. etc...

Feb 17, 2011 11:19 AM in response to fjenkins

fjenkins,

You may have to set the limits in three places for this to work.
1) sysctl
2) launchd
3) shell

See the man page for launchd.conf for more information, but you should be able to create a per user or system wide launchd.conf file in the following locations:
<pre>FILES
$HOME/.launchd.conf Your launchd configuration file (currently unsupported).
/etc/launchd.conf The system's launchd configuration file.</pre>

Something like the following would be good from your /etc/sysctl.conf snippet: <pre>limit maxproc 1024 2048</pre>

Lastly, double check your shell ulimit - you may still need a ulimit command in your shell rc file.

Oddly enough I've found the oracle documentation to be decent for tuning Mac to be more like a vanilla LAMP server since it's such a resource hog. Do check to see why you have so many processes. Perhaps you can thin the load - but if not, these tips should help you set higher limits every boot.

http://www.oracle.com/technetwork/topics/macos/whatsnew/index.html

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

fork: Resource temporarily unavailable

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.