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: 89
Total answers/comments: 5
Guest [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).
Guest [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
Guest [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...
Guest [Entry]

You can press Ctrl + C.
Guest [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"