- Creating a slice of length numFDs and later appending elements to it
results in a slice whose first numFDs elements are all nil. It is
sufficient to create a slice of zero length since we are appending
elements to it.
- The current allocation will make ret a slice of length 0. What's
needed is a slice of length len(ofs).
darwin will not perform correctly if there are spaces in the actual
arguments, in which case a single argument will be reported as
multple. Some CGO would be needed to get around this I think.
I couldn't find any good documentation on how windows handles
command line arguments with spaces inside the actual arguments, so
this implementation merely just splits on spaces.
Before it was doing a fillFromStatus() call which was much slower
and none of the information was needed, except by the Name() func
which now will call fillFromStatus() if p.name is not set.
This allows for getting more exact information about each argument
especially if there are arguments that have spaces in them.
This was not implemented for darwin or for windows because they
both currently have not way of properly parsing the cmdline string.
Darwin parses the output of 'ps' which is already whitespace
segmented, and windows just has the cmdline string.
process.Process.uids is an array of undocumented values.
That one of them is the user that the process is running as is obvious, but what
the other two are supposed to be is AFAICT undocumented.
On Darwin, the second and third UID (out of three) seem to always be 0.
This change removes the two always-zero UIDs from the process.Process struct on
Darwin, and leaves just the one that actually identifies the user the process
is running as.
This function used to be a private part of process.go.
Since I needed that functionality however I think it's better to make it public
than for me to copy it into my own code.
As a side effect of this change, I also fixed a bug in the function where Stolen
was not part of the sum. Having the function close to the CPUTimesStat
declaration will make problems like this less likely to re-occur in the future.