go-ps
go-ps copied to clipboard
Out-of-memory during Process32NextW returns no error and truncated process list
Hi,
The loop in https://github.com/mitchellh/go-ps/blob/master/process_windows.go#L112 can return false for (A) successfully reaching the end of the list, or (B) some other error.
As per https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-process32nextw we must check GetLastError() for ERROR_NO_MORE_FILES after exiting this loop.
I encountered this problem today, on a PC under memory pressure, where this function returned a truncated process list.