Comments (24)
The command line should include the args in linux as well.
from sysinfo.
Are you saying that right now it should? Because it doesn't. Note how copy_from_file() returns a Vec, and then there's a get(0) for its return value, so only the first element in the vector is actually used.
from sysinfo.
I can work on a patch to change that of course. What do you think of a separate field for arguments?
from sysinfo.
Great idea! Thanks a lot for finding this out!
from sysinfo.
Ok, I will make a pullrequest probably after sleep.
from sysinfo.
No need to hurry, take your time. :)
from sysinfo.
Just to make sure that I got right what you wanted: I will add an args field for arguments, and I will make it so that cmd on linux contains the arguments, too. Yes?
from sysinfo.
I wonder if cmd will still be needed actually... Since we have the arg and the executable's path, I guess it can just be removed. The only is that you'll have to actually parse a command line, which isn't great. Maybe you should just fix the cmd which should take the whole command line instead of just the first argument.
from sysinfo.
Well, I'm thinking that if someone has to parse the command line, it should be the library, not the user, right? Otherwise all the users who need the arguments have to parse them
from sysinfo.
But this isn't what this library is about. It doesn't parse such things, it just gathers information.
from sysinfo.
Ok, then I'll just fix the cmdline
from sysinfo.
Thanks! :)
from sysinfo.
Hrm! This is a bad idea actually I think. This is what happens on Mac OS currently:
$ ./testprogram "foo bar" foo bar
command: ./testprogram foo bar foo bar
On linux the same thing would happen, as a library user you have absolutely no way to know when one argument stops and the next begins.
(testprogram just prints its own process information)
from sysinfo.
Huuuuu?! The quotes aren't kept?!
from sysinfo.
No, that's not how it works (otherwise every program would have to know how to handle them, that would be really awkward). They're eaten by the shell when it builds the arguments, so the process never sees them.
from sysinfo.
No don't worry, I know how it works (wrote a shell a few years ago). My point is that, I thought that when you check on a process information, the cmdline was untouched.
from sysinfo.
The linux/mac os kernel never sees the quotes, because they're gone before the process is launched by the shell. It's the same with a backspace to escape stuff.
from sysinfo.
Hum ok. On OSX it's easy to know when an argument ends since there is '\0' but I don't remember seeing such a thing in linux...
from sysinfo.
It's easy too, it's the same thing :) You even handle it in copy_from_file :)
from sysinfo.
Ah... Well then, cmdline should be converted from String
to Vec<String>
then. Such a shame I didn't pay more attention to it.
from sysinfo.
should we keep calling it cmdline or should it be args? Asking because a vec isn't a line anymore.
from sysinfo.
Well, it's still a command line at least. I think the wording should be kept, unless you have something better in mind?
from sysinfo.
Nope, it's cool. Ok, I'll see what I can do here :)
from sysinfo.
Thanks a lot!
from sysinfo.
Related Issues (20)
- OpenCloudOS get cpu_usage fail HOT 3
- Calling `Components::refresh_list` multiple times on M-series Mac causes segfault HOT 15
- Possible memory leak in `Disks::refresh_list` HOT 17
- Make Windows support optional HOT 2
- `test_refresh_memory` fails on macOS HOT 1
- Global cpu usage is occasionally smaller than the sum of all process CPU usage HOT 2
- Get HW ID for each Disk HOT 3
- No temperature output for Mac M3 Pro HOT 4
- Incorrect CPU arch HOT 1
- Refreshing multiple processes on macos leads to invalid cpu usage HOT 3
- Add more hardware info: PCI devices, graphics adapters, CPU instruction sets HOT 1
- missing info from cmd of a process HOT 9
- cgroup free and available memory HOT 2
- Global CPU usage is incorrect on Mac M3 Pro HOT 2
- Process parent is `None` if the target process of `refresh_process_specifics()` is a WoW64 process HOT 1
- global cpu info HOT 3
- Add OpenBSD support HOT 3
- Typo in documentation of `Networks::new_with_refreshed_list()`
- International Money Transfer to Ghana: Key Developments and Benefits
- Does system::processes_by_exact_name() return all threads on Linux? 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.