Re: How to find out if process is in a loop? In General, the problem of finding whether a problem is in an infinite
loop or not is np hard. Can't be done. For more information refer
"introduction to theory of computation" - Ullman.
What i normally would do is to start kdb command and see the stack of
the program which i suspect to be in an infinite loop. If i keep seeing
the same stack repeatedly something is a problem.
Then I see how much cpu the process is using. If its exceptionally
high, then there is a good chance it is in an infinite loop.
Of course, the last thing I would do is to actually go to the code from
the stack trace in either kdb, or if i wanted more information what is
going on, I would make a debug build of the program and attach dbx to
it and analyse. That normally how I work.
But there definitely is no sure shot way of knowing whether a program
is going into an infinite loop or not.
Thanks and regards,
Rajbir Bhattacharjee
Jurjen Oskam wrote:
> On 2006-11-12, Hemant Shah <shah@typhoon.xnet.com> wrote:
>
> > I have the source code, and the problem occurs when programmer
> > makes change to the application and runs it. The programmer may not monitor
> > the program so as sys admin I want to be able to catch it before it affects
> > other users.
>
> My point was: you can't tell whether a program is in an infinite loop from the
> outside. With knowledge about how the program *should* behave, you can try to
> determine whether the program still functions correctly. For example, if the program
> was designed to write a line to a file every 5 seconds, you know there's something
> wrong when this doesn't happen. But even then, the problem might not be in the
> program itself: the machine it's running on may be overloaded.
>
> Your best solution is to think of a way to monitor the program from a script.
> You need to find criteria to determine if the program is still correctly running,
> and this depends greatly on the particular program.
>
> --
> Jurjen Oskam |