Home » Questions » Computers [ Ask a new question ]

How to break out of a program in an infinite loop?

How to break out of a program in an infinite loop?

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

Asked by: Guest | Views: 313
Total answers/comments: 5
bert [Entry]

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).
bert [Entry]

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
bert [Entry]

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...
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...
bert [Entry]

You can press Ctrl + C.
bert [Entry]

"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"