If your code fork()s inside a loop that runs forever and without any
sort of a pause, you will end up creating a fork bomb. You can read
more about them here: http://en.wikipedia.org/wiki/Fork_bomb.
The machines limit the number of processes a user can spawn to prevent
a fork bomb for taking down the host machine when on the remlnx
machines. However, if you fork bomb, you will reach that number of
processes and will be unable to do anything with your user account
until EWS cleans it up. We strongly suggest you use a bash shell when
doing any testing of this MP and setting the bash shell to limit the
maximum number of processes that can be sub-process of that bash shell.
Thus even if you reach the limit for your bash shell, you have not
reached your machine limit. Therefore, you can launch another shell
(eg: another instance of `putty`) and go in and kill your processes.
To limit the number of processes that can be spawned from the bash
shell, use the following commands:
%> bash # to enter the bash shellAfter accidental fork bomb, open a new bash shell, and identify the IDs of the processes that you have to kill:
%> ulimit -u 20 # max processes to 20
...
%> make # make/compile your program
%> ./shell # run your program)
%> ps -aef | grep NETID
root 13116 7645 0 Sep07 ? 00:00:00 sshd: NETID [priv]
NETID 13123 13116 0 Sep07 ? 00:00:00 sshd: NETID@pts/4
NETID 13124 13123 0 Sep07 pts/4 00:00:00 ./shell
NETID 14281 13124 0 00:07 pts/4 00:00:00 ./shell
...
NETID 14282 13124 0 00:07 pts/4 00:00:00 ./shell
The second column (the first column with numbers) shows the process
ID
of the running process. You should go about stopping all the processes
that are running ./shell and then killing all the processes running
./shell.
To stop a running process with ID = PID, use the command:
%> kill -STOP PID
And, to kill the process, use the command:
%> kill -KILL PID
And at this point, you're now set to start working again. Not fun, and
thus the importance of making doubly sure that your fork() code is
correct.