Of course the one liner you wrote won't work since the $1 is inside the quotes. Try this:
ps| gawk '{ if ($4 != "COMMAND" && $4 != "sh" && $4 != "ps") system("kill -KILL "$1) }'
Have fun but use it with caution. I generally don't like system commands in gawk, certainly not the "kill" command.
Recent versions of the nVidia proprietary drivers (possibly combined with other recent versions of libraries) have a bug which causes them to corrupt the signal mask.
You can look at signal masks like this:
anthony@Zia:~$ ps -eo blocked,pid,cmd | egrep -v '^0+ '
BLOCKED PID CMD
fffffffe7ffbfeff 605 udevd --daemon
0000000000000002 4052 /usr/lib/policykit-1/polkitd --no-debug
0000000000087007 4646 /usr/sbin/mysqld --basedir=/usr […]
0000000000010000 15508 bash
That's about what it should look like. If you run that on a system with the proprietary nVidia drivers, you'll see all kinds of crazy values for BLOCKED
, for many of your programs—including, likely, all the misbehaving ones.
Note that signal masks are passed from parent to child through fork
/exec
, so once a parent process has a corrupt one, all the children it spawns from that point forward will, too.
See also my question After upgrade, X button in titlebar no longer closes xterm and various distro bugs you'll be able to find now, knowing which package to look at. You can modify the code in my answer to that question to reset the signal mask to none blocked (Elide sigaddset
and change SIG_UNBLOCK
to SIG_SETMASK
).
Best Answer
From
man htop
:Not quite the answer you were looking for, but close. You can also eliminate process groups or children with kill, see:
https://stackoverflow.com/questions/392022/best-way-to-kill-all-child-processes