IEEE-VIT / termiboard

A smart CLI Dashboard to fetch cpu, memory and network stats!
MIT License
35 stars 16 forks source link

[BUG] Process with PID: 0 access denied as it is system idle process in Windows #30

Closed sjchoure closed 3 years ago

sjchoure commented 3 years ago

Describe the bug Since the PID of system processes in Windows and Unix differ, for example, PID 0 and PID 1 in *nix are given to the Scheduler and the Init Process respectively. Note: Unix PID starts from 1 PID 0 and PID 4 in Windows are given to the System Idle Process and the Init Process respectively. Note: Windows PID starts from 4

So, the System Idle Process in Windows is generally not accessible by the userland programs not even by the administrative privileges.

To Reproduce Steps to reproduce the behavior:

  1. Run the current program in Windows and the Output is as follows: Githubwin

Expected behavior

  1. Running the same program in *nix based OS gave the desired Output. GithubNewIssue

Additional context (Optional) The solution is to slice off the PID = 0 if present in the Processes Slice inside the memory.go file. This result in the desired output without the error as follows:

Github Issue Note: We still require to "Run as an Admin" to get the desired result

DarthBenro008 commented 3 years ago

@saviourcode i would highly suggest you add a os check (using GOOS ) and then slice of PID 0 if its windows

sjchoure commented 3 years ago

@saviourcode i would highly suggest you add a os check (using GOOS ) and then slice of PID 0 if its windows

Yeah, that way is more acceptable and maintainable in long run, rather than slicing random PID: 0, 😃 Okay I will make the changes.