What's the best way to kill a process and all its child processes from a Perl script? It should run at least under Linux and Solaris, and not require installation of any additional packages.
My guess would be to get a list of all processes and their parents by parsing files in /proc or by parsing the output of ps
(neither of which seems portable between Linux and Solaris); and then killing all processes in the tree (which seems prone to race conditions).
I could live with the race conditions in this particular case, but how do I portably get the process list?