Best way to kill all child processes forked by a given program
Firstly, find the process group leader (i.e. master process that forked other processes) of the program, e.g. apache2
# sudo ps x -o "%p %r %y %x %c " | grep apache2 14787 14787 ? 00:00:00 apache2
To verify if it is the process leader.
# pgrep apache2 | sort -n | head -n1 14787
To issue kill to all the members in the process group
# kill -9 -14787