Jump to content

TR-01: How to kill programs without killing linux


Guest fubar::chi
 Share

Recommended Posts

Guest fubar::chi

Browse: [About the FAQ Forum] [Table of Contents] [FAQs] [Contribute] [GQ: General Questions not covered in the other sections]

 

TR-01: How to kill programs without killing linux

 

I'm sure many of you have heard that "linux is more stable than windows" but are somewhat surprised when that odd program takes over and you have no recourse but to hit the reset button. Well I'm hear to tell you that that reset button may not be necessary.

There are many ways to end errant programs without killing linux (reset switch) which many times will run perfectly once that program is dealt with.

I'll start with X (XFree86 Windowing System which provides the GUI) and work my way down to the console methods.

 

::X gonna give it to ya::

If you use KDE and you experience problems with a program which doesn't want to close (in spite of you pressing the close button) you first recourse is something provided by KDE.

1. If you press Ctrl+Alt+Esc-clicking on a window will also get rid of the skull.

2.I've found this method to be quick but rather messy at times as the program is still using up resources. You can open KDE System Guard from the menu Kmenu -> Applications -> Monitoring -> KDE System Guard button to see the updated list of applications.

There may be more than one of the programs with the same name listed. Instead of clicking on them all you can choose the Tree view to kill the top-most (parent) application which will then kill the rest. The Tree view is obtained by clicking on the box next to Tree.

You can also sort programs by there memory usage which is especially useful if you don't know a program's name. Programs that have gone bad will usually use a lot of memory and show up at the top when sorted under User%. You can then select this program and kill it. This is good if it is a child process which has frozen and not a parent (with other children who are ok).

3. There is also the option of using XKill which is provided in the default Mandrake installation under Kmenu -> Applications -> Monitoring -> Xkill-clicking anywhere on the desktop.

4. There is also a kill-clicking on the window decoration.

5. If an application is using up so much resources that your PC is too slow for you to bring up the menu or wait for KDE System Guard then there is always the Ctrl+Alt+Backspace combo which will kill X itself.

 

::Killing a la Console::

You can also kill apps from the console using the kill commands.

1. To kill programs using the kill where username is your user name (since, unless you are root, you cannot kill other users' programs).

2. The killall

3. I also use top to kill the program. If it's still alive after that I repeat, only this time i use 9 as the signal. Occasionally signal 9 doesn't work and I've always wondered why.

*[3] Why can't I kill a process with -9?

 

One of the early things people learn about Unix is that a "kill -9" is

invincible- that a process must die if you send it a KILL (-9).

However, that's not entirely true:

  • A process can be sleeping in kernel code. Usually that's because
    of faulty hardware or a badly written driver- or maybe a little of
    both. A device that isn't set to the interrupt the driver thinks
    it is can cause this, for example- the driver is waiting for
    something its never going to get. The process doesn't ignore your
    signal- it just never gets it.
     
  • A zombie process doesn't react to signals because it's not really
    a process at all- it's just what's left over after it died. What's
    supposed to happen is that its parent process was to issue a
    "wait()" to collect the information about its exit. If the parent
    doesn't (programming error or just bad programming), you get a
    zombie. The zombie will go away if it's parent dies- it will be
    "adopted" by init which will do the wait()- so if you see one
    hanging about, check its parent; if it is init, it will be gone
    soon, if not the only recourse is to kill the parent..which you
    may or may not want to do.
     
  • Finally, a process that is being traced (by a debugger, for
    example) won't react to the KILL either.

See SCO TA 104438 for more details.

 

::Terminal Death::

Before you ask no this isn't the same thing as the previous section. I can see that some clarification is necessary so I'll explain. In the context that I'm using it the console is what you use when you log in without X (i.e. that big black screen asking you to log in). The terminal on the other hand is what you use inside of X when using konsole or Eterm, etc. (Any *n*x gurus out there who know better feel free to correct my terminology :D).

First off, you can use all the methods used in Killing a la Console commands need to be done as root.

1. In case of a total freeze as oppose to intense system slowdown it may be time for the Alt+SysRq sequences.

2. If only X has frozen (usually you can only move the mouse) you can get away with not doing all the SySRq sequences. This works for me

  • At this point X sometimes dies a horrible, painful death. If not The next one is sure to do the job and always drops me to a console
     
  • Alt+SysRq+I.
     
  • While doing some research i also found that Alt+SysRq+K fails this should work.
     
  • When i get to the console all i do is login as root then init 1
    Whew, well that's it. Happy exterminating.

::References::

 

[1]Information provided by paul

[2]Provided by tyme

Link to comment
Share on other sites

 Share

×
×
  • Create New...