I use Controller() to see if a particular process has YourKit agent attached to it. Sometimes the function never returns for certain process ids. That last time it happened, I checked which process it freezes at, and it was calc.exe.
I tried to reproduce the problem by closing and starting another instances of windows calculator application, but I was unable to get it to freeze.
Previously, I have had the same problem when using overloaded controller constructor that uses hostname and agent port. - Controller(String, Int32)
Execution hangs at controller constructor
-
- Posts: 6172
- Joined: Wed Aug 11, 2004 8:37 am
Re: Execution hangs at controller constructor
How did you get the PID list?
Do you mean you enumerated all processed on the machine and applied the Controller(int pid) constructor to each PID?
Do you mean you enumerated all processed on the machine and applied the Controller(int pid) constructor to each PID?
-
- Posts: 24
- Joined: Wed May 16, 2012 3:08 pm
Re: Execution hangs at controller constructor
Yes. Is there any other way?
-
- Posts: 6172
- Joined: Wed Aug 11, 2004 8:37 am
Re: Execution hangs at controller constructor
Check only those processes for which the profiler agent log file exists.
The following pseudo-code illustrates how to do it:
Please don't forget to replace <user home directory> with the home directory under which the applications to be detected has been started.
The following pseudo-code illustrates how to do it:
Code: Select all
int[] allPIDs = ...; // get all PIDs as you do it now
foreach (int pid in allPIDs)
{
if (File.Exists("<user home directory>/.ynp/log/" + pid + ".log)) {
// ... perform the check with new Controller() as you do it now...
}
}
-
- Posts: 6172
- Joined: Wed Aug 11, 2004 8:37 am
Re: Execution hangs at controller constructor
Also, you can periodically cleanup the log file directory <user home directory>/.ynp/log to reduce probability to hit an old log file created for a finished application whose PID by chance matches the PID of one of the currently running processes which are not started with the profiler.
-
- Posts: 6172
- Joined: Wed Aug 11, 2004 8:37 am
Re: Execution hangs at controller constructor
By the way, could you please explain your intention. Why do you need to list all processes with the agent loaded?
-
- Posts: 24
- Joined: Wed May 16, 2012 3:08 pm
Re: Execution hangs at controller constructor
We using it to auto-collect all snapshots at real-time and store them in a centralized data store, so people can go back to any time and see how the application was performingAnton Katilin wrote:By the way, could you please explain your intention. Why do you need to list all processes with the agent loaded?
-
- Posts: 24
- Joined: Wed May 16, 2012 3:08 pm
Re: Execution hangs at controller constructor
Thanks. I think this method is a bit more efficient also.Anton Katilin wrote:Check only those processes for which the profiler agent log file exists.
The following pseudo-code illustrates how to do it:Please don't forget to replace <user home directory> with the home directory under which the applications to be detected has been started.Code: Select all
int[] allPIDs = ...; // get all PIDs as you do it now foreach (int pid in allPIDs) { if (File.Exists("<user home directory>/.ynp/log/" + pid + ".log)) { // ... perform the check with new Controller() as you do it now... } }