Code Monkey home page Code Monkey logo

Comments (5)

GuillaumeGomez avatar GuillaumeGomez commented on May 31, 2024

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.

GuillaumeGomez avatar GuillaumeGomez commented on May 31, 2024

Ok, this is from the thread status and not the process status. Adding it.

from sysinfo.

davechallis avatar davechallis commented on May 31, 2024

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.

GuillaumeGomez avatar GuillaumeGomez commented on May 31, 2024

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.

davechallis avatar davechallis commented on May 31, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.