GithubHelp home page GithubHelp logo

Comments (24)

GuillaumeGomez avatar GuillaumeGomez commented on August 25, 2024

The command line should include the args in linux as well.

from sysinfo.

shahn avatar shahn commented on August 25, 2024

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.

shahn avatar shahn commented on August 25, 2024

I can work on a patch to change that of course. What do you think of a separate field for arguments?

from sysinfo.

GuillaumeGomez avatar GuillaumeGomez commented on August 25, 2024

Great idea! Thanks a lot for finding this out!

from sysinfo.

shahn avatar shahn commented on August 25, 2024

Ok, I will make a pullrequest probably after sleep.

from sysinfo.

GuillaumeGomez avatar GuillaumeGomez commented on August 25, 2024

No need to hurry, take your time. :)

from sysinfo.

shahn avatar shahn commented on August 25, 2024

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.

GuillaumeGomez avatar GuillaumeGomez commented on August 25, 2024

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.

shahn avatar shahn commented on August 25, 2024

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.

GuillaumeGomez avatar GuillaumeGomez commented on August 25, 2024

But this isn't what this library is about. It doesn't parse such things, it just gathers information.

from sysinfo.

shahn avatar shahn commented on August 25, 2024

Ok, then I'll just fix the cmdline

from sysinfo.

GuillaumeGomez avatar GuillaumeGomez commented on August 25, 2024

Thanks! :)

from sysinfo.

shahn avatar shahn commented on August 25, 2024

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.

GuillaumeGomez avatar GuillaumeGomez commented on August 25, 2024

Huuuuu?! The quotes aren't kept?!

from sysinfo.

shahn avatar shahn commented on August 25, 2024

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.

GuillaumeGomez avatar GuillaumeGomez commented on August 25, 2024

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.

shahn avatar shahn commented on August 25, 2024

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.

GuillaumeGomez avatar GuillaumeGomez commented on August 25, 2024

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.

shahn avatar shahn commented on August 25, 2024

It's easy too, it's the same thing :) You even handle it in copy_from_file :)

from sysinfo.

GuillaumeGomez avatar GuillaumeGomez commented on August 25, 2024

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.

shahn avatar shahn commented on August 25, 2024

should we keep calling it cmdline or should it be args? Asking because a vec isn't a line anymore.

from sysinfo.

GuillaumeGomez avatar GuillaumeGomez commented on August 25, 2024

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.

shahn avatar shahn commented on August 25, 2024

Nope, it's cool. Ok, I'll see what I can do here :)

from sysinfo.

GuillaumeGomez avatar GuillaumeGomez commented on August 25, 2024

Thanks a lot!

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.