Re: killing all processes of one user reliably



Dnia Wed, 31 Jan 2007 06:22:54 -0800, patrick napisał(a):

I've been researching ways to kill all processes of one user (while
being root, of course) and I couldn't find _one_ program doing it
without race conditions.
I think the most popular such programs are "skill" (from procps) and
"slay".

The program is called "kill" -- why re-invent the wheel?

kill -9 `ps -u username | grep -v TTY | awk '{print $1}'`

Because it doesn't always work!
Your one-liner effectively does the same as "skill" and is prone to the
same race condition. It is even easier to win this race because it's
slower (shell commands vs C program).

Let's say you have a server and one of your users does something really
bad. You disable his cron jobs, "at" jobs, disallow logging through ssh,
delete all his files etc. But the user managed to start a bunch of
"antiskill.c" programs from the webpage I mentioned. Even if you run your
one-liner lots of times, it won't work.
What do you do? Reboot the server?

Noix
.



Relevant Pages

  • Re: killing all processes of one user reliably
    ... without race conditions. ... I think the most popular such programs are "skill" (from procps) and ...
    (comp.os.linux.security)
  • Re: open() behavior under heavy disk load
    ... effects which may be created because of race conditions ... server never recovers from the backup. ... Bad programmers will do anything badly. ... Odd corner bug cases are not unique to threads. ...
    (comp.os.linux.development.system)