Yes, although it may not be enabled by default on your system. The setrlimit
system call defines system limits -- including the number of processes per user.
Let's look at it first in the kernel API (since you mentioned "linux"): you can use the manpage for setrlimit, which will tell you to do something like
#include <sys/resource.h>...struct rlimit r;rnew.r_cur = 40;rnew.r_max = 50;setrlimit(RLIMIT_NPROC,&r);
This will set the maximum processes per user (RLIMIT_NPROC
) to 40 (soft limit) and 50 (hard limit).
Now, from the shell, if you use bash, you can use the ulimit
built-in command:
ulimit -u29089
You can set the limit by passing it as an argument:
ulimit -u 100
ulimit --help
will show you that there are several other limits you can set (one which may be of interest is the maximum number of file descriptors used by the user).