Skip to content

Conversation

@addisonElliott
Copy link

@addisonElliott addisonElliott commented Apr 17, 2018

Fixes issue #11.

Uses different approach from #56. When going through each file, if the file contains a space (meaning multiple arguments) and we're not on Windows, then it will attempt to use the following method to get the correct arguments.

It reads all lines from proc//cmdline. This contains the command used where each argument is separated by a NUL (0x00) character rather than spaces. So this means any spaces that are within the arguments themselves will be ignored.

Some particular notes:

  • I couldn't find any references, but I believe /proc//cmdline is widely supported by all *nixes. This may be worth investigating to be sure.
  • /proc//cmdline presents itself as a file but is probably stored in memory somewhere. Thus, I believe this approach should be fast to read since there is no calls to disk.

Interested in input, but I believe this method will be faster than #56 because in one file read it knows what the correct command arguments are rather than trying all combinations.

Credit goes to @moos because I basically used his test from PR and modified to get it working. Quite brilliant actually!

…unded by quotations

This is done by calling /proc/<PID>/cmdline where the arguments are separated by NUL characters rather than spaces. This can then be split up and parsed.
@addisonElliott
Copy link
Author

@herve-g Can you try out this code if you get a chance? It should resolve your issue.

Also, I am interested to see if my PR slows things down. In theory, I don't think so but it can't hurt to be sure.

@addisonElliott
Copy link
Author

/proc//cmdline does not work for OS X. Will need to do additional research.

Plus side is that this is working for Linux systems?

@addisonElliott addisonElliott deleted the check-for-spaces branch April 19, 2018 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant