Commit Graph

60 Commits (a9c2f23bc2fcea5d4da58d476a2b2da6cb7fb214)

Author SHA1 Message Date
shirou 145dca90f7 change to use CommandContext.
shirou 6a368fb7cd [process]: add ProcessesWithContext.
shirou cd61c36c4f
Merge branch 'master' into feature/add_context_support
Nick Kirsch 6c35887d02 Add ErrNotImplementedError to Darwin, FreeBSD, and OpenBSD.
shirou 4c73494c78 Add WithContext functions.
Sam Kleinman 4d92a03da8 fix cross compiles
tycho garen 08a382b207 make process.processes function public
Leonid Podolny 7ee4a4c6ff Fix Threads() signature to better match python original
Leonid Podolny 7ad3836ad3 Implement Threads() for Linux
shirou a452de7c73 Merge pull request #346 from phemmer/rlimit-current
add current values to rlimit retrieval
Chris Roberts 9c998f664a Fix process.Exe() on macOS 10.12
The `lsof` command on macOS < 10.12 always selects the `p` field
when using the `-F` option. On macOS 10.12 the `f` field is also
always selected causing an incorrect result. This modification adds
both options which are always selected to maintain consistency.
Sean Chittenden 635b971c0e
Move from the `syscall` package to the `golang.org/x/sys/{unix,windows}`
Patrick Hemmer 60c32eb847 add current values to rlimit retrieval
Sean Chittenden d0e40ff723
Fix issues reported by golint.
tycho garen 6110db7ab5 error earlier on darwin for get parent pid
Nex 189b8e6d12 Fixed missing bin and unused stderr
Nex b6a7649aab Error handling
Nex d9b355f75e Added proper piping of commands
Nex dd3cbcc611 Trying remove single quotes
Nex 1534b109ae Fixing pid name
Nex 8c3e7bd255 Casting pid properly
Nex 9659355f49 Checking content
Nex 8bb06aca3d Fixed type casting
Nex 5481d93989 Fixing assignment of vars
Nex 4f7834af25 Added attempt to get exe path from pid
Tom Elliott 1435987652 Correctly handle long running processes on OSX
The full etime format is dd-hh:mm:ss. Replacing '-' with ':' fixes parsing of this format.
Tom Elliott 3855e7ba0e Implement CreateTime for darwin. Parses elapsed time and converts this to epoch time.
Shirou WAKAYAMA 613a8a90e1 fixed by golint.
Shirou WAKAYAMA 944429d994 fixed by errcheck
Shirou WAKAYAMA 46ddd57c72 process has NetIOCounters and IOCounters.
Shirou WAKAYAMA ea152ea901 [BREAKING CHANGE] rename functions to pass golint. ex) net.NetIOCounters -> net.IOCounters
Chris Gilling 8c186ae593 process: add CmdlineSlice for darwin + windows
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.
Chris Gilling b8c40ac83c process: add CmdlineSlice function for linux + freebsd
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.
Johan Walles 70444b571b process: Implement platform independent MemoryPercent()
It calls mem.VirtualMemory() and process.MemoryInfo(), so on the platforms where
those work MemoryPercent() will as well.

Tested on Darwin.
Shirou WAKAYAMA e21c97d3b2 [process]darwin: forget to change as binary.go movement.
Johan Walles 09fbecef59 Darwin: Remove questionable UIDs
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.
Johan Walles e3a7a45492 process.Username(): Correct user names on Darwin
Before this change, process.Username() returned "root" for all processes on
Darwin.
Heretic a0692cc17a 1)fix callps command generate error
shirou 9d8191d6a6 Merge pull request #137 from shirou/process/add_netiocounter_for_linux
[WIP] net,process[linux]: add process.NetIOCounter and net.NetIOCounterByFile.
Cameron Sparr f251637a93 Add -a when calling ps on darwin
Shirou WAKAYAMA d680853370 net,process[linux]: add process.NetIOCounter and net.NetIOCounterByFile.
Olivier Vielpeau ec627e67ac process[darwin] Fix unit of RSS and VMS
Should be bytes, `ps` returns Kbytes.
Shirou WAKAYAMA dd13300833 process[linux,freebsd,darwin]: implements Children using pgrep.
Shirou WAKAYAMA 7288e9a5af common[all]: add internal
Shirou WAKAYAMA b3cf7354f6 process[linux, darwin]: implements Connections using lsof.
Shirou WAKAYAMA c50db4f462 net[darwin]: implement NetConnections().
Shirou WAKAYAMA d6ac361a24 process[darwin,linux]: implements Parent using lsof.
Shirou WAKAYAMA fc513b6f9a proces[darwin]: change exec.Command to interface to enable mocking.
Add common.invoker interface to mock exec.Command. common.FakeInvoker returns
expected file if exists instead of invoke exec.Command.
Currenly, mocking is enabled only process.Pids(). I will expand to other funcs incrementally.
jay park 2984accfa1 return error when CPUTimes fails on callPs, modify comments on ReadLines
Hideo Hattori 4d4bd26b06 implement NumThreads on darwin. use ps command