0

I am writing a simple code which sets the Nproc prlimit to 0. I then try to fork a process which should generate an error. But the child is created. I tried creating multiple children and there seems to be no error message ever.

import resource,os
resource.prlimit(os.getpid(),resource.RLIMIT_NPROC,(0,0))
print(resource.getrlimit(resource.RLIMIT_NPROC))

os.fork()
os.fork()
print("a")

Output:

(0, 0)
a
a
a
a

The same thing happened when I set the limit using ulimit -u.

Is this the expected behaviour?

  • I am not 100% certain on this so I won't attempt an answer, but your system most likely will not like you setting your root process to a limit of zero (it is the parent of all running processes). Have you considered creating a new process and then trying to set the limit of that process instead? – Kush May 31 '16 at 19:00
  • I've tried doing that but I get the same result. – Trickster Jun 02 '16 at 07:44

0 Answers0