Comments (5)
They seem to use the exact same values as I do: https://github.com/giampaolo/psutil/blob/master/psutil/_psutil_osx.c#L1885
So maybe they extra another information and what you get is the result?
from sysinfo.
Ok, this is from the thread status and not the process status. Adding it.
from sysinfo.
Thanks, just gave this a test, looks a bit better, but still getting an unusually higher number of "None" results from this, e.g. running:
extern crate sysinfo;
use sysinfo::SystemExt;
fn main() {
let mut system = sysinfo::System::new();
system.refresh_all();
for (pid, process) in system.get_process_list() {
println!("{}:{} thread_status={:?}, process_status={:?}",
pid, process.name, process.status, process.process_status);
}
}
Now outputs e.g.:
740:com.apple.quicklook.ThumbnailsAgent thread_status=None, process_status=Some(Run)
517:trustd thread_status=None, process_status=Some(Run)
1577:fsnotifier thread_status=None, process_status=Some(Run)
52643:mdworker thread_status=None, process_status=Some(Run)
46463:python thread_status=None, process_status=Some(Run)
679:callservicesd thread_status=None, process_status=Some(Run)
8136:com.apple.audio.ComponentHelper thread_status=None, process_status=Some(Run)
516:lsd thread_status=None, process_status=Some(Run)
9785:MTLCompilerService thread_status=None, process_status=Some(Run)
1528:MTLCompilerService thread_status=None, process_status=Some(Run)
45511:Slack Helper thread_status=Some(Waiting), process_status=Some(Run)
951:loginitemregisterd thread_status=None, process_status=Some(Run)
827:com.apple.WebKit.WebContent thread_status=None, process_status=Some(Run)
29680:bash thread_status=None, process_status=Some(Run)
52003:iTerm2 thread_status=None, process_status=Some(Run)
50716:ssh thread_status=None, process_status=Some(Run)
1151:com.apple.accessibility.mediaaccessibilityd thread_status=None, process_status=Some(Run)
9784:MTLCompilerService thread_status=None, process_status=Some(Run)
1154:com.apple.audio.SandboxHelper thread_status=None, process_status=Some(Run)
801:storelegacy thread_status=None, process_status=Some(Run)
50587:XprotectService thread_status=None, process_status=Some(Run)
1150:com.apple.Safari.SafeBrowsing.Service thread_status=None, process_status=Some(Run)
52668:com.apple.iCloudHelper thread_status=None, process_status=Some(Run)
8376:com.docker.osxfs thread_status=None, process_status=Some(Run)
677:bird thread_status=None, process_status=Some(Run)
52664:quicklookd thread_status=None, process_status=Some(Run)
51085:iTerm2 thread_status=None, process_status=Some(Run)
1580:idea thread_status=Some(Waiting), process_status=Some(Run)
817:MTLCompilerService thread_status=None, process_status=Some(Run)
1123:com.apple.CommerceKit.TransactionService thread_status=None, process_status=Some(Run)
52603:vim thread_status=None, process_status=Some(Stop)
52389:tcom thread_status=None, process_status=Some(Run)
854:FolderActionsDispatcher thread_status=Some(Waiting), process_status=Some(Run)
798:ctkahp thread_status=None, process_status=Some(Run)
862:NotificationCenter thread_status=Some(Waiting), process_status=Some(Run)
46456:python thread_status=None, process_status=Some(Run)
45691:AirPort Base Station Agent thread_status=Some(Waiting), process_status=Some(Run)
802:soagent thread_status=None, process_status=Some(Run)
Seeing a few with status Some(Waiting)
, but doesn't seem that so many should have a status of None
(unless I'm misunderstanding what sysinfo is returning here, which is entirely possible :) ).
Happy to help doing some more testing next week.
from sysinfo.
None
means I couldn't get the information (generally because the application needs more rights). I appreciate this differentiation with Unknown
so that people can make the difference. However, might be worth adding a comment explaining this behaviour.
(And yes, I appreciate your tests a lot!)
from sysinfo.
@GuillaumeGomez I had a chance to do a bit more testing today. I'm not sure it's a rights issue after some experimenting (but could well be wrong - I'm not that familiar with Rust or OS X's syscalls!).
I can e.g. start a new process (owned by me) and set it to sleep immediately (e.g. python -c 'import time; time.sleep(99999)'
) which has some pid (say 77480).
Output from sysinfo on this process is:
77480:python thread_status=None, process_status=Some(Run)
However, output from ps aux
shows it as sleeping:
dsc 77480 0.0 0.0 2417912 6892 s016 S 10:24am 0:00.06 python
Additionally, I seem to be able to get info on that process when making the syscalls directly from C, e.g.:
#include <stdio.h>
#include <stdlib.h>
#include <sys/proc_info.h>
int main(int argc, char **argv) {
struct proc_taskallinfo info;
int ret = proc_pidinfo(atoi(argv[1]), PROC_PIDTASKALLINFO, 0, &info, sizeof(struct proc_taskallinfo));
printf("status=%d, ret_val=%d\n", info.pbsd.pbi_status, ret);
return 0;
}
Outputs the following when run on the pid from above:
status=2, ret_val=232
So it looks like all the info on that pid was able to be read. Conversely, running the above against a process owned by root outputs:
status=0, ret_val=0
as I'd expect.
Not sure if this helps, but let me know if there's anything else I can do :)
from sysinfo.
Related Issues (20)
- sunxi-therm_temp1 temperature in wrong scale HOT 4
- Sysinfo causing program to crash on m1 mac HOT 2
- Physical memory larger than virtual memory on Windows HOT 4
- global_cpu_info().brand() returning M1 instead of Intel on Intel based Macs HOT 2
- Drop once_cell dependency once MSRV can be bumped to 1.70 HOT 1
- Free memory is wrong on Linux with gcroups v2 HOT 10
- Hot plug support HOT 3
- incorrect process cpu usage? HOT 12
- can not get cpu usage in mac os 14.4 (23E214) HOT 1
- Unable to Retrieve User Groups on Windows HOT 1
- Remove `new_all` methods
- Println not working after refresh_cpu() HOT 3
- Temperatures on Linux unavailable HOT 1
- Is it possible to add volume_serial_number to the disk?
- the process API on macOS can returned non UTF-8 String HOT 8
- Add memory frequency, type, and slot information HOT 1
- Only store CPU usage for global CPU and no other information HOT 1
- Return std::result HOT 4
- Add `serde::Serialize` for all the output types HOT 1
- Process priority/affinity support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sysinfo.