user379217
user379217

Reputation: 81

ulimit first call ok second call fail, why?

On macosx 10.7, using bash

The first call to ulimit -n succeeds, while the second fails.

a:$ ulimit -n 
2560
a:$ ulimit -n 5000
a:$ ulimit -n 
5000
a:$ ulimit -n 6000
bash: ulimit: open files: cannot modify limit: Operation not permitted

however if I try in a new shell (or another shell) to ulimit -n 6000, it succeeds:

a:$ ulimit -n 
2560
a:$ ulimit -n 6000
a:$ ulimit -n 
6000

Why is that?

Upvotes: 4

Views: 1644

Answers (1)

Doug Stephen
Doug Stephen

Reputation: 7351

From the bash man page:

A hard limit cannot be increased once it is set; a soft limit may be increased up to the value of the hard limit. If neither -H nor -S is specified, both the soft and hard limits are set.

Most modern *NIX's don't actually use ulimit anymore. I'd guess that OS X has no ulimit hard max set, so your first call sets the soft and hard max, and so your second call fails every time. The first call without a [limit] parameter is probably printing the soft max.

Upvotes: 4

Related Questions