(Note: The program mentioned was written for a class assignment, but this question is not part of the assignment; it is for my own curiosity and I cannot find an answer elsewhere.)
For a class assignment, I needed to write a program to determine the number of simultaneous processes that could be run by a user at once. My program creates a certain number of processes before fork()
returns -1 because the limit has been reached, then it terminates those processes and ends.
When I run as root
, it counts 16 created processes before terminating them, which makes sense. The Minix 2 man page for fork()
specifies that the limit is set by the NR_PROCS
variable in /usr/include/minix/config.h
, and that is set to 32. root
is running 16 processes in addition to the 14 created by the program (+2 for shell and the program itself), so that makes a total of 32 processes.
When I run as the unprivileged user ast
, however, the program only returns 13 (so it's only spawning 11 processes plus the two for shell and program). I'm using su ast
to run as the ast
user, but I don't know if that process is taken into account. UPDATE: Logging in as ast
causes the program to spawn 12 processes, so adding the two for shell and the program itself means ast
can only have 14 simultaneous processes running (the user is not running any others).
Why is there a difference in the number of processes that can be run by superusers and unprivileged users, especially when only one variable controls the system limit?