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.

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
    
add comment

7 Answers

pkill myAppName

share|improve this answer
add comment

get the PID of the process:

  ps -ef | grep <the name here>

then,

  kill -9 <PID>
share|improve this answer
add comment

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

is a nice oneliner for this.

share|improve this answer
add comment

or try killall -9 myAppName.

share|improve this answer
add comment

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
add comment

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
add comment
up vote 0 down vote accepted

CTRL-C is what I was looking for.

share|improve this answer
add comment

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.