Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Occasionally, when I'm developing on my Mac, I'll get a process that hangs. When that happens, I'll try the following:

  1. Ctrl + C in the active terminal window
  2. If nothing happens, I'll open a new terminal window and do kill -SIGTERM {PID}
  3. If still nothing, close the terminal window.

I'm running into situations where after doing both 1 and 2, the PID is still listed in my list of processes. In other words, there doesn't seem to be a command-line option to kill the process - all I can do is kill terminal.

In Linux command-line environments, we obviously don't have option 3. So do command-line interrupts operate differently there? Is there another way to kill processes I'm overlooking? What is the 'last resort' option for killing a Linux process?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Same as in OS X: Send SIGKILL.

share|improve this answer
    
Sweet thanks Ignacio –  Yarin Aug 5 '12 at 22:53
    
I don't know that I've ever upvoted such a short answer. –  killermist Aug 6 '12 at 3:16
    
@killermist: Some things are hard to answer, and require a full essay in order to be complete. Some things are easy. –  Ignacio Vazquez-Abrams Aug 6 '12 at 3:17

You can try Ctrl + \ (control backslash), which sends the QUIT signal. This often works when SIGINT has been trapped.

Sometimes a process will ignore signals, because it is stopped.

You can use something like this, to kill a process gracefully if possible:

KILL() {
  kill -CONT "$@"
  kill -TERM "$@"
  kill -HUP "$@"
  sleep 1
  kill -KILL "$@"
}

KILL 12345

Even this might not always work. If there is some I/O error, such as a missing device, for example.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.