getrlimit and randomness

Posted Aug 6, 2009

To determine the maximum number of files your application can open, there is a function getrlimit() available.

Here is what tells us the man page:

int getrlimit(int resource, struct rlimit *rlp);
A resource limit is specified as a soft limit and a hard limit.
When a soft limit is exceeded a process may receive a signal (for example, if the cpu time or file size is exceeded),
but it will be allowed to continue execution until it reaches the hard limit (or modifies its resource limit).
The rlimit structure is used to specify the hard and soft limits on a resource,
struct rlimit {
rlim_t rlim_cur; /* current (soft) limit */
rlim_t rlim_max; /* hard limit */
};

Let's create an application to print the soft and hard limit. I simply created a new Cocoa project and add this awakeFromNib function: