Processes Out of Control? Just STOP Them (Unix Power Tools, 3rd Edition)
24.17. Processes Out of Control? Just STOP Them
Especially if you're a
programmer, you can run into a situation where you have
processes forking (Section 24.2) out of
control -- more and more of them. By the time you kill one, fifty
more fork.
On systems with job control
(Section 23.3), there's a good answer: use
the STOP signal to stop the processes:
kill Section 24.12
kill -STOP ...
Stop any process you can so that it can't fork more
processes. Stop them all. Then start cleaning up with kill
-9.
If your system manager has set a per-user process limit on your
computer, the good news is that your processes won't
eventually crash the system. But the bad news is, when you try to run
any command that isn't built
into the shell (Section 1.9) (like
killall (Section 24.16), which would be nice to use in this
situation, if you have it):
% killall -STOP myprog
No more processes.
you can't because you're already at
your limit.
If that happens, log on to another account or ask someone to run a
command that will give a list of your processes. Depending on your
system, the command is probably like one of these two:
% ps -u yourname
System V
% ps aux | grep yourname
BSD
Then go back to your terminal and
start stopping :-). If you get the No
more processes error, your shell must
not have a built-in kill command. Many shells
do -- including bash and
csh. Carefully type the next
commands to be sure that /bin/bash exists
(assuming your shell has a built-in echo, this
trick[76] bypasses the external ls
command); then, if the shell is there, replace your shell with
bash. Don't make a mistake (if
you do, you may not be able to log in again):
[76]This trick uses the shell's
built-in wildcard matching (Section 1.13) to show you the shell's
name -- we hope. If you get an answer like
/bin/bas?, or multiple answers that
don't include /bin/bash, try
another shell name. (Maybe your bash is in
/usr/local/bin, for instance.) If you get an
answer like No more processes, though, your
echo command probably isn't built
in.
exec Section 36.5
$ echo /bin/bas?
/bin/bash
$ exec /bin/bash
bash$ kill ...
-- JP
24.16. Kill Processes Interactively24.18. Cleaning Up an Unkillable Process
Copyright © 2003 O'Reilly & Associates. All rights reserved.
Wyszukiwarka
Podobne podstrony:
ch24 (9)ch24 (16)ch24ch24 (10)ch24ch24ch24ch24 (8)ch24CH24ch24ch24 (5)ch24 (13)CH24 (12)ch24ch24 (6)ch24!ch24!ch24więcej podobnych podstron