Operating System - Linux
1755132 Members
2777 Online
108830 Solutions
New Discussion юеВ

How To identify A hang Process in Linux

 
DhsDheeraj
Occasional Advisor

Re: How To identify A hang Process in Linux

I think dfunct represents the Zombie process.But the requirement is to monitor all processes.
dirk dierickx
Honored Contributor

Re: How To identify A hang Process in Linux

you can also take a look at what the process is doing with the 'strace' command. either no output appears for a long time. or you see the same calls appearing all the time, which could mean it's stuck in a loop.
Srimalik
Valued Contributor

Re: How To identify A hang Process in Linux

Hi, Dheeraj

The problem seems to be vague, why would somebody want to monitor a client(mozilla), One should worry about the hang of a server and not a client.

Still as you say you want to know if a process has not done anything for some specified amount of time(you need to fix a limit on that)-Also process consuming no cpu is not hanged always. What you can do is:

have a look at /proc//stat

This has a lot of numbers includeing the accounting information. You can extract the cpu time consumed in a loop and go on checking the previous value with the new value if they both are same for quite some time(you decide the time) you can take it a hanged.

-Sri
abandon all hope, ye who enter here..
Matti_Kurkela
Honored Contributor

Re: How To identify A hang Process in Linux

The problem seems to be almost equivalent to the Halting Problem of computability theory.

See Wikipedia's article about the Halting Problem:
http://en.wikipedia.org/wiki/Halting_problem

Any modern computer is essentially a Turing machine. Alan Turing proved in 1936 that there are no general solutions in the Halting Problem. In other words, your task is *impossible* unless you can get some extra information or are willing to accept some false detections.

For example, the problem becomes much easier if you have a way of determining whether the program is making progress or not. For server programs that take in requests and process them, this is usually easy: determine the maximum acceptable time to process a request, and if the program is spending much more time with one request it's probably hung.

Or you could simply monitor the length of the queue of unprocessed requests: if the queue grows too long, there is a problem.

For interactive programs like a web browser, the "queue" is in the user's mind, so your program cannot determine the queue length. You'll have to add some assumptions, for example:
- when the browser process has a large %CPU value, it is probably drawing a new page to the display
- nobody will want to wait 10 minutes for a webpage to be displayed
- so if the browser has a large %CPU value for 10 minutes continuously, it's probably hung
But someday you might need to read a super-heavy web page which takes 11 minutes to display on your old computer...


Assumptions like this are always specific to the type of program (web browser) and are not correct for any other type of program. For example, if a database engine is processing a lot of requests, it may have a high %CPU for hours at a time. But if your system is getting a lot of work done, that's exactly what is supposed to happen.

MK
MK