I work with Terminal a lot, and often have 30 to 40 windows open, each running my shell and ssh. Add in all the other processes, and I quickly exceed the 100 maxprocperuid limit that OS X defaults to.
There have been many proposed solutions to this. You can for instance in your shell startup scripts override the limit for that shell instance, and you can run more than 100 processes from that shell, but when you launch a new window, the parent process that launches all apps for you in the GUI is still limited to that 100 process per user limit, and the new window will fail to launch your shell. Usually with the error: login: fork: Resource temporarily unavailable.
There are thre phases to fixing this problem. First you must change the over all OS limits for maxproc and maxprocperuid to higher values, change the environment daemons get started up under via rc.common, and then you must make WindowServer run in an environment with the limits raised.
System Wide
OS X 10.3 now supports the standard /etc/sysctl.conf. This means you can just put new values into this file and reboot.
>cat /etc/sysctl.conf
# Turn up maxproc
kern.maxproc=2048
# Turn up the maxproc per user
kern.maxprocperuid=512
/System/Library/StartupItems are started with the default
maxproxperuid of 100. This might not normally be a problem as root may not run a ton of processes, but it does matter when sshd is started up. On OS X sshd is started out of xinetd. A quick way to affect the environment of xinetd
and all other daemons as well, is to put ulimit -u 512 at the top of /etc/rc.common.
If you preferred, you could just edit the startup script for xinetd instead which is /System/Library/StartupItems/IPServices/IPServices
Here is a snippet of the top of my /etc/rc.common file:
####################### # Configure the shell # ####################### ulimit -u 512 ## # Be strict ##
WindowServer
Every process you run from the GUI is launched by WindowServer. So we need to make WindowServer launch in such a way that it has its limits raised. I cannot determine what actually launched WindowServer. Its parent process is mach_init, and I can find no way to modify how it is launched directly.
You can however write a wrapper script for WindowServer. A shell script that is launched instead of WindowServer it self, that sets the limits properly, then launches the original WindowServer as normal.
cd /System/Library/Frameworks/ApplicationServices.framework/\
Frameworks/CoreGraphics.framework/Resources/
mv WindowServer WindowServer.orig
vi WindowServer
#!/bin/zsh
ulimit -u 384
/System/Library/Frameworks/ApplicationServices.framework/\
Frameworks/CoreGraphics.framework/Resources/WindowServer.orig "$*"
chmod a+rx WindowServer
reboot
The requested page could not be found.