summaryrefslogtreecommitdiff
path: root/psutil/_psutil_windows.c
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-01-03 15:55:39 -0800
committerGiampaolo Rodola <g.rodola@gmail.com>2020-01-03 15:55:39 -0800
commiteb4ffe954252ce080118a9a1322b133f456163c7 (patch)
tree1d3a6a1cb7c163a8f1321d997486b34d548d682c /psutil/_psutil_windows.c
parent089dcff0067beb35e699f9da57d04b8fb6824132 (diff)
downloadpsutil-eb4ffe954252ce080118a9a1322b133f456163c7.tar.gz
windows: move get_process_info() into process_info.c to make room for Cygwin
Diffstat (limited to 'psutil/_psutil_windows.c')
-rw-r--r--psutil/_psutil_windows.c88
1 files changed, 0 insertions, 88 deletions
diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c
index ba86040b..a98e1c4d 100644
--- a/psutil/_psutil_windows.c
+++ b/psutil/_psutil_windows.c
@@ -1542,94 +1542,6 @@ psutil_proc_num_handles(PyObject *self, PyObject *args) {
}
-/*
- * Get various process information by using NtQuerySystemInformation.
- * We use this as a fallback when faster functions fail with access
- * denied. This is slower because it iterates over all processes.
- * Returned tuple includes the following process info:
- *
- * - num_threads()
- * - ctx_switches()
- * - num_handles() (fallback)
- * - cpu_times() (fallback)
- * - create_time() (fallback)
- * - io_counters() (fallback)
- * - memory_info() (fallback)
- */
-static PyObject *
-psutil_proc_info(PyObject *self, PyObject *args) {
- DWORD pid;
- PSYSTEM_PROCESS_INFORMATION process;
- PVOID buffer;
- ULONG i;
- ULONG ctx_switches = 0;
- double user_time;
- double kernel_time;
- long long create_time;
- PyObject *py_retlist;
-
- if (! PyArg_ParseTuple(args, "l", &pid))
- return NULL;
- if (! psutil_get_proc_info(pid, &process, &buffer))
- return NULL;
-
- for (i = 0; i < process->NumberOfThreads; i++)
- ctx_switches += process->Threads[i].ContextSwitches;
- user_time = (double)process->UserTime.HighPart * HI_T + \
- (double)process->UserTime.LowPart * LO_T;
- kernel_time = (double)process->KernelTime.HighPart * HI_T + \
- (double)process->KernelTime.LowPart * LO_T;
-
- // Convert the LARGE_INTEGER union to a Unix time.
- // It's the best I could find by googling and borrowing code here
- // and there. The time returned has a precision of 1 second.
- if (0 == pid || 4 == pid) {
- // the python module will translate this into BOOT_TIME later
- create_time = 0;
- }
- else {
- create_time = ((LONGLONG)process->CreateTime.HighPart) << 32;
- create_time += process->CreateTime.LowPart - 116444736000000000LL;
- create_time /= 10000000;
- }
-
- py_retlist = Py_BuildValue(
-#if defined(_WIN64)
- "kkdddiKKKKKK" "kKKKKKKKKK",
-#else
- "kkdddiKKKKKK" "kIIIIIIIII",
-#endif
- process->HandleCount, // num handles
- ctx_switches, // num ctx switches
- user_time, // cpu user time
- kernel_time, // cpu kernel time
- (double)create_time, // create time
- (int)process->NumberOfThreads, // num threads
- // IO counters
- process->ReadOperationCount.QuadPart, // io rcount
- process->WriteOperationCount.QuadPart, // io wcount
- process->ReadTransferCount.QuadPart, // io rbytes
- process->WriteTransferCount.QuadPart, // io wbytes
- process->OtherOperationCount.QuadPart, // io others count
- process->OtherTransferCount.QuadPart, // io others bytes
- // memory
- process->PageFaultCount, // num page faults
- process->PeakWorkingSetSize, // peak wset
- process->WorkingSetSize, // wset
- process->QuotaPeakPagedPoolUsage, // peak paged pool
- process->QuotaPagedPoolUsage, // paged pool
- process->QuotaPeakNonPagedPoolUsage, // peak non paged pool
- process->QuotaNonPagedPoolUsage, // non paged pool
- process->PagefileUsage, // pagefile
- process->PeakPagefileUsage, // peak pagefile
- process->PrivatePageCount // private
- );
-
- free(buffer);
- return py_retlist;
-}
-
-
static char *get_region_protection_string(ULONG protection) {
switch (protection & 0xff) {
case PAGE_NOACCESS: