2

When running a program that goes into an infinite loop in the terminal, how would I bring back the command prompt?

(I'm using Fedora core 5)

jonsca
  • 4,077
  • 15
  • 35
  • 47
trinity
  • 191
  • 2
  • 3
  • 8

8 Answers8

11

You could send a SIGHUP (Ctrl-Z) or SIGTERM (Ctrl-C). The former merely pauses the program, you may resume with fg (or resume as a background process, using bg).

Victor Nicollet
  • 236
  • 1
  • 5
3

You'll have to kill the program using Ctrl + C where C stands for Cancel.

Tamara Wijsman
  • 57,083
  • 27
  • 185
  • 256
1

Either Ctrl-C as mentioned, or if that should not work, open another terminal, find the process using ps -ef|grep , find the process ID (pid), and use the kill command: kill -9

Thilo
  • 161
  • 4
0

you can press ctrl + z type: ps ux ,to see the running process, if the one you want to kill is there

type: kill -9 processId , where the process id is the loop process id

bonzi
  • 11
0

You can press Ctrl + C.

Gaff
  • 18,569
  • 15
  • 57
  • 68
Justin Niessner
  • 259
  • 1
  • 3
0

Launch the program with & at the end to cause it run in the background. Note that if you exit the terminal, the application might/will stop as well.

root@root:~$ run_app with params &

Using Ctrl+C will kill it if you forgot the &.

0

There is no way to prove that any arbitrary program will ever end without actually running it to the end.

Having said that, it is possible to set up a watchdog via e.g. D-Bus that can kill a program if a response is not received within a given amount of time.

Ignacio Vazquez-Abrams
  • 111,361
  • 10
  • 201
  • 247
0

As mentioned, you can simply add a & to the command line. You can also hit CTRL-Z (this puts the process in the Stopped state), and then type bg to get it running in the background again...

dicroce
  • 101
  • 2