toggle background image
RunawayProcess
Some navigation will not work unless JavaScript is enabled
 All Links: Showv | Hide^ 

ITP Help

Special Requests

Dates/Hours v

Curriculum v

ITP Resources v

Off Floor Resources v

Tech Notes v

ITP Community v

Showing Work v

Servers v

ITP Policies v

Orientation/Registration v







Help / RunawayProcess

Runaway Process / Infinite Loop

(or a Background Process)

When a program gets caught in an infinite loop (the condition to end the repeat loop is never met), it uses up resources on the server and will continue to use resources until it is stopped (killed). If you're testing in a web browser, pressing the browser's stop button or closing the browser does NOT necessarily stop the process. You need to ssh/telnet into your account.

If you're running the program from the command line of an ssh/telnet session, it can usually be stopped with a cntl-C. If this doesn't work you will need to open another ssh/telnet session and stop the process from there.

The following are instructions for stopping a "run-away" program in your account on itp.nyu.edu.

After you have successfully logged into your account and get a command prompt, type:

ps -U netid (that's a capital U)

You will get a list like:

PID TTY TIME CMD
18608 ? 00:00:00 sshd
18609 pts/0 00:00:00 bash
30765 ? 00:00:00 program_name.cgi
31220 pts/0 00:00:00 ps

If that doesn't give you enough information try:

ps -U netid -x (this gives more information)

or

ps -ux (the lowercase -ux gives even more info)

To kill program_name.cgi, type:

kill pid (pid - process id number)
kill 30765 (for the example above)
if there are several instances of program_name.cgi, you might want to use: pkill program_name.cgi (to end all of them)

Then: ps -U netid if program_name.cgi is still there then type:

kill -9 pid
kill -9 30765 (for the example above)
pkill -9 program_name.cgi (if more than one instance)

Then repeat: ps -U netid It should be gone by then.

kill pid#/pkill program_name.cgi is the gentler way to kill a process -- tell the program to stop. Sometimes when a program is in an infinite loop it doesn't even "hear" the request to stop. kill -9 pid#/pkill -9 program_name.cgi will stop the process whether it's "listening" or not.

In general though, use kill first and only use kill -9 if the kill doesn't work.

Page last modified on November 14, 2008, at 10:11 PM