go-ps icon indicating copy to clipboard operation
go-ps copied to clipboard

Out-of-memory during Process32NextW returns no error and truncated process list

Open mappu opened this issue 4 years ago • 0 comments

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.

mappu avatar Jul 29 '21 04:07 mappu