1

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?

3

7 Answers 7

3
pkill myAppName

2

get the PID of the process:

  ps -ef | grep <the name here>

then,

  kill -9 <PID>
2

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

is a nice oneliner for this.

1

or try killall -9 myAppName.

1

ps -aux | grep "name of the program"

will give you the id of the program and then:

kill -9 <id of the programm>

0

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

2
  • How can I run these commands while my program is still looping?
    – Nosrettap
    Commented Feb 19, 2012 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? Commented Feb 19, 2012 at 21:37
0

CTRL-C is what I was looking for.

You must log in to answer this question.

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