How can I get the state of a program?
Asked Answered
S

2

6

I'm observing an program and want to kill it, if it is for some time in the state "wait:executive".

Here is a screenshot of the Process Explorer:

State: wait:executive

How can I get that state by code? Or could maybe tell me somebody what that state exactly mean? This will may help me to find the right query to solve my problem.

Soares answered 24/9, 2012 at 9:33 Comment(4)
Information should be somewhere in PCB of a process. Is this windows 8?Jowett
No that is in Windows 7.Soares
It's perfectly normal for the main thread of an application to be waitingDanettedaney
@DavidHeffernan That is in my case a console application which should do its work and exit. But when I start it from my vb script the application hangs in some (reproducible) cases. But it works with the same command line in cmd fine.Soares
F
2

It is not state of program but it's state of thread.One process can have many threads.

You can call WaitForSingleObject to determine some states.

Also you can instantiate WMI using COM and selecting Win32_Thread class.

Here is some example.

More info here : How to determine that a win32 thread is either in Wait or Join or Sleep state in c++

Frequency answered 24/9, 2012 at 10:18 Comment(1)
Thank you for that hints. I'll need some time to understand and implement that.Soares
H
2

It means the thread is waiting for the scheduler/a component of the executive

It can be fetched with WMI Win32_Thread (or .net System.Diagnostics.ProcessThread WaitReason)

Haematozoon answered 24/9, 2012 at 10:10 Comment(0)
F
2

It is not state of program but it's state of thread.One process can have many threads.

You can call WaitForSingleObject to determine some states.

Also you can instantiate WMI using COM and selecting Win32_Thread class.

Here is some example.

More info here : How to determine that a win32 thread is either in Wait or Join or Sleep state in c++

Frequency answered 24/9, 2012 at 10:18 Comment(1)
Thank you for that hints. I'll need some time to understand and implement that.Soares

© 2022 - 2024 — McMap. All rights reserved.