Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortened processes names #86

Open
aellwein opened this issue Sep 22, 2020 · 4 comments
Open

Shortened processes names #86

aellwein opened this issue Sep 22, 2020 · 4 comments
Labels

Comments

@aellwein
Copy link

Please provide any of the following information if relevant:

While iterating through psutil::process::processes(), the processes names are somehow shortened.
if pid and name are printed, i see only the starting parts, like "Google Chrome He" instead of "Google Chrome Helper"
and so on.

@cjbassi
Copy link
Collaborator

cjbassi commented Sep 26, 2020

Can you give a minimal example? Also which field is it that's shrunk, cmdline or name?

@aellwein
Copy link
Author

aellwein commented Sep 27, 2020

Sure! A simple example

fn main() {
    let ps_vec = psutil::process::processes().unwrap();
    for res in ps_vec {
        match res {
            Ok(ps) => println!("PID: {:?} NAME: {:?}", ps.pid(), ps.name().unwrap()),
            Err(_) => {}
        }
    }
}

this produces (excerpt):

PID: 33189 NAME: "psutil-rs"
PID: 33028 NAME: "MTLCompilerServi"
PID: 33027 NAME: "Activity Monitor"
PID: 32917 NAME: "Google Chrome He"
PID: 32912 NAME: "Google Chrome He"
PID: 32742 NAME: "Google Chrome He"
PID: 31838 NAME: "rust-analyzer-ma"
PID: 31833 NAME: "VSCodium Helper "
PID: 31785 NAME: "VSCodium Helper "
PID: 31783 NAME: "gitstatusd-darwi"
PID: 29975 NAME: "QuickLookUIServi"
PID: 28642 NAME: "VTDecoderXPCServ"
PID: 47726 NAME: "com.apple.CoreSi"
PID: 13694 NAME: "com.apple.WebKit"
PID: 9044 NAME: "MTLCompilerServi"
PID: 9043 NAME: "MTLCompilerServi"
PID: 25967 NAME: "com.apple.audio."
PID: 25934 NAME: "com.apple.audio."
PID: 21592 NAME: "recentsd"
PID: 15433 NAME: "IMAutomaticHisto"
PID: 15322 NAME: "AMPArtworkAgent"
PID: 15321 NAME: "com.apple.audio."
PID: 15320 NAME: "com.apple.BKAgen"
PID: 15319 NAME: "PodcastContentSe"
PID: 406 NAME: "QuickLookUIServi"
PID: 405 NAME: "backgroundtaskma"
PID: 402 NAME: "accountsd"
PID: 401 NAME: "rapportd"
PID: 377 NAME: "coreauthd"
PID: 190 NAME: "loginwindow"

BTW using cmdline() doesn't work at all:

fn main() {
    let ps_vec = psutil::process::processes().unwrap();
    for res in ps_vec {
        match res {
            Ok(ps) => println!("PID: {:?} NAME: {:?}", ps.pid(), ps.cmdline().unwrap()),
            Err(_) => {}
        }
    }
}

produces

thread 'main' panicked at 'not yet implemented', /Users/alex/.cargo/registry/src/github.com-1ecc6299db9ec823/psutil-3.2.0/src/process/sys/macos/process.rs:103:9
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic
   7: psutil::process::sys::macos::process::<impl psutil::process::process::Process>::sys_cmdline
   8: psutil::process::process::Process::cmdline
   9: psutil_rs::main
  10: std::rt::lang_start::{{closure}}
  11: std::rt::lang_start_internal
  12: std::rt::lang_start
  13: main

P.S.: i tried with psutil 3.1.0, 3.2.0 and also with the version mentioned above, they all produce the same results.

@cjbassi
Copy link
Collaborator

cjbassi commented Sep 27, 2020

I tried the example on Linux and it seems to be working for me, so it must be a bug with the name method on macos.

@cjbassi cjbassi added the bug label Sep 27, 2020
@aellwein
Copy link
Author

I just stumbled upon this issue:
heim-rs/heim#262

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants