Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2019-03-12 13:34:50 +0300
committerCorinna Vinschen <corinna@vinschen.de>2019-03-12 13:34:50 +0300
commit57f1c81fb3e4a2581f5421350315755b07e509c8 (patch)
treecb6305ee442786b0819bb0ab2bcd121e3ab17f38
parent4ce7e1bbaacf007197e348e4d11ec6258f508873 (diff)
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>
-rw-r--r--winsup/cygwin/fhandler_process.cc70
1 files changed, 38 insertions, 32 deletions
diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc
index 576c5cbd0..31cd50700 100644
--- a/winsup/cygwin/fhandler_process.cc
+++ b/winsup/cygwin/fhandler_process.cc
@@ -1091,12 +1091,12 @@ format_process_stat (void *data, char *&destbuf)
NTSTATUS status;
HANDLE hProcess;
- VM_COUNTERS vmc;
- KERNEL_USER_TIMES put;
- PROCESS_BASIC_INFORMATION pbi;
- QUOTA_LIMITS ql;
- SYSTEM_TIMEOFDAY_INFORMATION stodi;
- SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION spt;
+ VM_COUNTERS vmc = { 0 };
+ KERNEL_USER_TIMES put = { 0 };
+ PROCESS_BASIC_INFORMATION pbi = { 0 };
+ QUOTA_LIMITS ql = { 0 };
+ SYSTEM_TIMEOFDAY_INFORMATION stodi = { 0 };
+
hProcess = OpenProcess (PROCESS_QUERY_LIMITED_INFORMATION,
FALSE, p->dwProcessId);
if (hProcess == NULL)
@@ -1104,38 +1104,44 @@ format_process_stat (void *data, char *&destbuf)
DWORD error = GetLastError ();
__seterrno_from_win_error (error);
debug_printf ("OpenProcess: ret %u", error);
- return 0;
}
-
- status = NtQueryInformationProcess (hProcess, ProcessVmCounters,
- (PVOID) &vmc, sizeof vmc, NULL);
- if (NT_SUCCESS (status))
- status = NtQueryInformationProcess (hProcess, ProcessTimes,
- (PVOID) &put, sizeof put, NULL);
- if (NT_SUCCESS (status))
- status = NtQueryInformationProcess (hProcess, ProcessBasicInformation,
- (PVOID) &pbi, sizeof pbi, NULL);
- if (NT_SUCCESS (status))
- status = NtQueryInformationProcess (hProcess, ProcessQuotaLimits,
- (PVOID) &ql, sizeof ql, NULL);
- CloseHandle (hProcess);
- if (NT_SUCCESS (status))
- status = NtQuerySystemInformation (SystemTimeOfDayInformation,
- (PVOID) &stodi, sizeof stodi, NULL);
- if (NT_SUCCESS (status))
- status = NtQuerySystemInformation (SystemProcessorPerformanceInformation,
- (PVOID) &spt, sizeof spt, NULL);
- if (!NT_SUCCESS (status))
+ else
{
- __seterrno_from_nt_status (status);
- debug_printf ("NtQueryInformationProcess: status %y, %E", status);
- return 0;
+ status = NtQueryInformationProcess (hProcess, ProcessVmCounters,
+ (PVOID) &vmc, sizeof vmc, NULL);
+ if (!NT_SUCCESS (status))
+ debug_printf ("NtQueryInformationProcess(ProcessVmCounters): status %y",
+ status);
+ status = NtQueryInformationProcess (hProcess, ProcessTimes,
+ (PVOID) &put, sizeof put, NULL);
+ if (!NT_SUCCESS (status))
+ debug_printf ("NtQueryInformationProcess(ProcessTimes): status %y",
+ status);
+ status = NtQueryInformationProcess (hProcess, ProcessBasicInformation,
+ (PVOID) &pbi, sizeof pbi, NULL);
+ if (!NT_SUCCESS (status))
+ debug_printf ("NtQueryInformationProcess(ProcessBasicInformation): "
+ "status %y", status);
+ status = NtQueryInformationProcess (hProcess, ProcessQuotaLimits,
+ (PVOID) &ql, sizeof ql, NULL);
+ if (!NT_SUCCESS (status))
+ debug_printf ("NtQueryInformationProcess(ProcessQuotaLimits): "
+ "status %y", status);
+ CloseHandle (hProcess);
}
+ status = NtQuerySystemInformation (SystemTimeOfDayInformation,
+ (PVOID) &stodi, sizeof stodi, NULL);
+ if (!NT_SUCCESS (status))
+ debug_printf ("NtQuerySystemInformation(SystemTimeOfDayInformation): "
+ "status %y", status);
fault_count = vmc.PageFaultCount;
utime = put.UserTime.QuadPart * CLOCKS_PER_SEC / NS100PERSEC;
stime = put.KernelTime.QuadPart * CLOCKS_PER_SEC / NS100PERSEC;
- start_time = (put.CreateTime.QuadPart - stodi.BootTime.QuadPart)
- * CLOCKS_PER_SEC / NS100PERSEC;
+ if (put.CreateTime.QuadPart)
+ start_time = (put.CreateTime.QuadPart - stodi.BootTime.QuadPart)
+ * 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
apparently broken, for 32 and 64 bit target processes. 64 bit
processes get the correct base priority, even for 32 bit processes. */