Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently testing a C++ program on the command line of a linux machine and unfortunately it sometimes gets into infinite loops. Is there a way that, from the command line, I can kill this program?

share|improve this question

migrated from stackoverflow.com Feb 19 '12 at 20:37

This question came from our site for professional and enthusiast programmers.

3  
Like CTRL-C or with kill? – Fabio F. Feb 19 '12 at 20:35
    
How 'bout kill -9 pid – Pete Wilson Feb 19 '12 at 22:07
    
pkill myAppName

share|improve this answer

get the PID of the process:

  ps -ef | grep <the name here>

then,

  kill -9 <PID>
share|improve this answer

ps aux | grep "name of program" | cut -d ' ' -f 2 | xargs kill -9

is a nice oneliner for this.

share|improve this answer

or try killall -9 myAppName.

share|improve this answer

ps -aux | grep "name of the program"

will give you the id of the program and then:

kill -9 <id of the programm>

share|improve this answer

Use the ps command to learn the PID of your program's process, then kill to terminate the process.

share|improve this answer
    
How can I run these commands while my program is still looping? – Nosrettap Feb 19 '12 at 21:09
    
You can use control-Z to put your program in the background. But really, you should always have more than one shell when you're doing "real work" on a text-based interface. What if you need to look at one piece of code while you edit another? – David Schwartz Feb 19 '12 at 21:37
up vote 0 down vote accepted

CTRL-C is what I was looking for.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .