Ignoring fork-bomb in Ubuntu [closed]

I got an homework assignment to write a program that checks how many process a user can create (working in Ubuntu). I wrote the code which seems fine in theory. The problem is that when I run it, the system closes it and doesn’t allow it to run after 3-5 seconds of work. The only reason I could think of is a protection embedded in Ubuntu. Is there a way to ignore this and run my program? I tried running it with root permissions as well but no luck.

How my program works: The 1st process fork() a new one and the father is put in wait to his son, then the newly created process creates another process (fork again) and waits for it and so on, until fork() fails and then I print a counter. Then everything existing so no zombies are left.

Answer

I think you want to look in /etc/security/limits.conf, you’re likely hitting a defined nproc limit. The manpage for it describes the limits contained within. This is likely what’s killing your attempted forkbombing.

Attribution
Source : Link , Question Author : Danny , Answer Author : MDMarra

Leave a Comment