We are having problems getting process info from a short-lived process.
In java, if you use ProcessBuilder to create and start the chmod command: chmod +x <some file>, then checking for the process using sigar doesn't seem to work for us.
I am using ProcessQuery and PTLQ to lookup the process. If I wrap the invocation of chmod into a shell script and then lookup the process for the shell script, our code seems to detect that.
On the mac, the chmod command takes 0.003s, but the wrapper shell script takes 0.063s. So the current thinking is that the process being so short-lived may be the problem. However, maybe the query is the problem? Or something else?
I'm wondering if there is either a sigar limitation in detecting a short-lived process, or perhaps, there is another less obvious sigar technique to monitor a short-lived process like chmod?
Using our windows-only non-sigar solution to monitor a process, we can detect the short-lived processes; however, we would like a cross-platform solution using just sigar, if that is possible.
Could you share some more detail on what data you want to monitor from these short-lived processes? We could look at using mechanisms such as netlink on Linux, kqueue on BSD, etc., where we can be notified when a process is created, rather than "polling" the process list.
What is the windows-only solution you're using?
I'm picking up this thread for hyperguy. These are answers to your questions, Doug:
>> Could you share some more detail on what data you want to monitor from these short-lived processes?
We would like to get process id and these performance metrics:
1. CPU time: Sigar.getProcCpu()
2. Resident memory: Sigar.getProcMem().getResident()
>> We could look at using mechanisms such as netlink on Linux, kqueue on BSD, etc., where we can be notified when a process is created, rather than "polling" the process list.
Thanks. We will start looking at them. We would appreciate your ideas about how to use them.
>> What is the windows-only solution you're using?
We get process id this way:
NULL, // no inheritable process handle
NULL, // no inheritable thread handle
TRUE, // No handle inheritance
NULL, // no parent's env
NULL, // No starting directory.
DWORD pid = processInfo.dwProcessId;
We get CPU time this way:
We get working set (not resident memory) this way:
GetProcessMemoryInfo(pHandle, &pmc, sizeof(pmc))
int msize = pmc.WorkingSetSize;