Cygwin: proc: let stat info always succeed
There's no good reason to return blank if some of the info couldn't be collected. Drop useless call collecting SystemProcessorPerformanceInformation. Always return some valid start_time, even if we couldn't collect ProcessTimes. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
4ce7e1bbaa
commit
57f1c81fb3
|
@ -1091,12 +1091,12 @@ format_process_stat (void *data, char *&destbuf)
|
||||||
|
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
HANDLE hProcess;
|
HANDLE hProcess;
|
||||||
VM_COUNTERS vmc;
|
VM_COUNTERS vmc = { 0 };
|
||||||
KERNEL_USER_TIMES put;
|
KERNEL_USER_TIMES put = { 0 };
|
||||||
PROCESS_BASIC_INFORMATION pbi;
|
PROCESS_BASIC_INFORMATION pbi = { 0 };
|
||||||
QUOTA_LIMITS ql;
|
QUOTA_LIMITS ql = { 0 };
|
||||||
SYSTEM_TIMEOFDAY_INFORMATION stodi;
|
SYSTEM_TIMEOFDAY_INFORMATION stodi = { 0 };
|
||||||
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION spt;
|
|
||||||
hProcess = OpenProcess (PROCESS_QUERY_LIMITED_INFORMATION,
|
hProcess = OpenProcess (PROCESS_QUERY_LIMITED_INFORMATION,
|
||||||
FALSE, p->dwProcessId);
|
FALSE, p->dwProcessId);
|
||||||
if (hProcess == NULL)
|
if (hProcess == NULL)
|
||||||
|
@ -1104,38 +1104,44 @@ format_process_stat (void *data, char *&destbuf)
|
||||||
DWORD error = GetLastError ();
|
DWORD error = GetLastError ();
|
||||||
__seterrno_from_win_error (error);
|
__seterrno_from_win_error (error);
|
||||||
debug_printf ("OpenProcess: ret %u", error);
|
debug_printf ("OpenProcess: ret %u", error);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
status = NtQueryInformationProcess (hProcess, ProcessVmCounters,
|
status = NtQueryInformationProcess (hProcess, ProcessVmCounters,
|
||||||
(PVOID) &vmc, sizeof vmc, NULL);
|
(PVOID) &vmc, sizeof vmc, NULL);
|
||||||
if (NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
|
debug_printf ("NtQueryInformationProcess(ProcessVmCounters): status %y",
|
||||||
|
status);
|
||||||
status = NtQueryInformationProcess (hProcess, ProcessTimes,
|
status = NtQueryInformationProcess (hProcess, ProcessTimes,
|
||||||
(PVOID) &put, sizeof put, NULL);
|
(PVOID) &put, sizeof put, NULL);
|
||||||
if (NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
|
debug_printf ("NtQueryInformationProcess(ProcessTimes): status %y",
|
||||||
|
status);
|
||||||
status = NtQueryInformationProcess (hProcess, ProcessBasicInformation,
|
status = NtQueryInformationProcess (hProcess, ProcessBasicInformation,
|
||||||
(PVOID) &pbi, sizeof pbi, NULL);
|
(PVOID) &pbi, sizeof pbi, NULL);
|
||||||
if (NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
|
debug_printf ("NtQueryInformationProcess(ProcessBasicInformation): "
|
||||||
|
"status %y", status);
|
||||||
status = NtQueryInformationProcess (hProcess, ProcessQuotaLimits,
|
status = NtQueryInformationProcess (hProcess, ProcessQuotaLimits,
|
||||||
(PVOID) &ql, sizeof ql, NULL);
|
(PVOID) &ql, sizeof ql, NULL);
|
||||||
|
if (!NT_SUCCESS (status))
|
||||||
|
debug_printf ("NtQueryInformationProcess(ProcessQuotaLimits): "
|
||||||
|
"status %y", status);
|
||||||
CloseHandle (hProcess);
|
CloseHandle (hProcess);
|
||||||
if (NT_SUCCESS (status))
|
}
|
||||||
status = NtQuerySystemInformation (SystemTimeOfDayInformation,
|
status = NtQuerySystemInformation (SystemTimeOfDayInformation,
|
||||||
(PVOID) &stodi, sizeof stodi, NULL);
|
(PVOID) &stodi, sizeof stodi, NULL);
|
||||||
if (NT_SUCCESS (status))
|
|
||||||
status = NtQuerySystemInformation (SystemProcessorPerformanceInformation,
|
|
||||||
(PVOID) &spt, sizeof spt, NULL);
|
|
||||||
if (!NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
{
|
debug_printf ("NtQuerySystemInformation(SystemTimeOfDayInformation): "
|
||||||
__seterrno_from_nt_status (status);
|
"status %y", status);
|
||||||
debug_printf ("NtQueryInformationProcess: status %y, %E", status);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
fault_count = vmc.PageFaultCount;
|
fault_count = vmc.PageFaultCount;
|
||||||
utime = put.UserTime.QuadPart * CLOCKS_PER_SEC / NS100PERSEC;
|
utime = put.UserTime.QuadPart * CLOCKS_PER_SEC / NS100PERSEC;
|
||||||
stime = put.KernelTime.QuadPart * CLOCKS_PER_SEC / NS100PERSEC;
|
stime = put.KernelTime.QuadPart * CLOCKS_PER_SEC / NS100PERSEC;
|
||||||
|
if (put.CreateTime.QuadPart)
|
||||||
start_time = (put.CreateTime.QuadPart - stodi.BootTime.QuadPart)
|
start_time = (put.CreateTime.QuadPart - stodi.BootTime.QuadPart)
|
||||||
* CLOCKS_PER_SEC / NS100PERSEC;
|
* CLOCKS_PER_SEC / NS100PERSEC;
|
||||||
|
else
|
||||||
|
start_time = (p->start_time - to_time_t (&stodi.BootTime)) * CLOCKS_PER_SEC;
|
||||||
/* The BasePriority returned to a 32 bit process under WOW64 is
|
/* The BasePriority returned to a 32 bit process under WOW64 is
|
||||||
apparently broken, for 32 and 64 bit target processes. 64 bit
|
apparently broken, for 32 and 64 bit target processes. 64 bit
|
||||||
processes get the correct base priority, even for 32 bit processes. */
|
processes get the correct base priority, even for 32 bit processes. */
|
||||||
|
|
Loading…
Reference in New Issue