I never did this before, but now that I know that it works, I will do it more often.
To show how it works, I changed the number of processes (nproc) hard limit of the user koteo in the limits.conf to 10
With the prlimit command I display the limits of the first PID of user “koteo”, that matches with the limits of the file limits.conf
Now I execute bash until I get the error “Cannot fork”.
I execute prlimit with the parameter –nproc=1024:1024 (soft:hard) and the parameter –pid $pid (we get $pid from pgrep) . We just changed the soft and hard limit to 1024, as you could see at the bottom of the next screenshot.
Now I can execute again the bash command, after the error “Cannot fork”.
Here I show you, that we actually have more than 10 processes for koteo user.
If I’m not wrong, this started working with kernels 2.6.32+
I know that in few versions of the kernel works “echo -n “Max processes=SOFT_L:HARD_L” > /proc/$PID/limits” but not in the one that I have. It displays the error:
`write(2, “: Invalid argument”, 18: Invalid argument) = 18`