I ran this grep:

grep -r "\-\-\-foo\-\-\-" * | grep -vi bar

For the past 5 minutes my Mac has been running hot (I can hear the fan) and I can't hit Ctrlz or x or c to kill the current task.

Even the clock on my Mac hasn't updated in 6 minutes.

How can I kill the task?


Open new Terminal, then type top in your Terminal. You'll see the list of process running, like in the following image

enter image description here

You can see the grep process id here. then press q. It'll come back to terminal again. Then kill the two process using, kill command:,

kill 4963
kill 4934
| improve this answer | |

Ctrlz always works for me, to suspend the process and resume the shell terminal.


kill -9 <PID>


pkill -9 bar

usually does the trick.

[p]kill -9 sends the KILL signal to the process identified by Process ID, or executable name.

On an Ubuntu box, you can substitute <PID> for `jobs -p`, (with backticks), which just prints the process ID of other child processes of the current shell (hopefully only the process just suspended with Ctrlz).

On OSX, you have to type in the PID manually, or use pkill. You can find other child jobs' PID's with jobs -l (jobs -p doesn't work on OSX), which prints other information as well as the PID.

In the case that Ctrlz doesn't work, open a new terminal window up and identify the process ID with

ps aux | grep bar

and [p]kill as above.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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