Commit Graph

54 Commits

Author SHA1 Message Date
Chris Gianelloni a8418dfd73 feat: use lsof for net_connections on FreeBSD
Use net.ConnectionsPidWithContext on FreeBSD, similarly to how it is done
on Darwin. This uses common.CallLsofWithContext underneath the hood, which
will use lsof under the hood, if available.

Tested on FreeBSD 13.2-RELEASE

Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
2023-11-09 18:19:10 -05:00
Lomanic 8b96d2e9e2 [process][posix] Realign process.Name() with python psutil to return same value on python3 scripts processes
e2c79a1 started to blindly set the process name to the full path (instead of the basename) of the cmdline exectuable
if the process name from the process comm was truncated on linux. Python psutil never did that, and this is just wrong
for python (or any executable interpreted script) where the process name is not the interpreter binary but the script
itself.

A new test to check process name value against psutil value is added here, which would hopefully catch any potential
future changes in psutil.

Reverts #542

Fixes #1485
2023-07-09 00:43:24 +02:00
Donal Hurley cf25de7460 Add support for getting process exe in FreeBSD 2023-03-09 11:46:40 +00:00
Ville Skyttä f7e1f36418 refactor: remove unnecessary exec.LookPath calls
Executing the command does the lookup if needed and returns the same
error when not found, no need to do it separately.
2022-03-04 18:56:33 +02:00
Sergey Kozlov 8ae037c8a1 Fix typing issues in createTimeWithContext on Freebsd/i386
Before change:
```
$ GOOS=freebsd GOARCH=386 go build ./process
process\process_freebsd.go:118:26: cannot use k.Start.Sec * 1000 + k.Start.Usec / 1000 (type int32) as type int64 in return argument
```
2022-02-08 21:03:48 +00:00
Ville Skyttä 0306525d78 [process] implement ParentWithContext using PpidWithContext
Removes need for redundant ParentWithContext implementations. It had led
to it being unsupported on FreeBSD and OpenBSD even though
PpidWithContext was available for them, and different implementations
for getting the parent info used in ParentWithContext and
PpidWithContext on Darwin and Linux.
2022-01-22 18:27:52 +02:00
Ville Skyttä 41e2595443 [process][freebsd] implement createTimeWithContext 2022-01-05 01:20:20 +02:00
mmorel-35 1e6b445a8a gofumpt 2021-12-22 21:54:41 +00:00
shirou 0969c9436b delete v2 directory, move v3 to top #1078 2021-11-30 23:47:59 +00:00
Sergey Vinogradov 065e609cbf Refactor "process" package
* All context-less wrapping functions (the ones without WithContext
suffix) were moved into process.go since they all are the same.
* Call context is now passed to all underlying functions in
*WithContext() functions.
* All common *BSD bits were moved to process_bsd.go.
* Process.Tgid() method lacked a WithContext counterpart, so
Process.TgidWithContext() was added for uniformity.
* NewProcessWithContext() function was added since NewProcess() is
used a lot throughout the module, and there is no way to pass a
context to it.

This is a part of #761 effort.
2020-10-12 18:15:29 +03:00
shirou 7e94bb8bcd
Merge pull request #775 from TakayukiBGoto/add_additional_gids_support
[Process] Implement Groups() to get additional gids.
2020-07-24 22:09:41 +09:00
Lomanic 4f0e679e35 [process][darwin][openbsd][freebsd] Fix #795 don't truncate process names to 16 characters 2019-12-01 17:54:08 +01:00
TakayukiB Goto a93796494b [Process] Define the Groups() only once 2019-10-24 18:42:13 +09:00
TakayukiB Goto f55f202e81 [Process] Implement Groups() to get additional gids. 2019-10-07 12:59:36 +09:00
Lomanic 547679f88e [process] Fix #760 implement IsRunning by checking process with same PID has same CreateTime as current process 2019-09-07 18:54:49 +02:00
Lomanic 3eefe64948 [process] Fix #752 sort PIDS returned by process.Pids() 2019-08-24 09:08:28 +02:00
Lomanic 3465186bca [process] Fix #729 check process existence in NewProcess() 2019-08-01 21:12:48 +02:00
Lomanic 41e774419f
Merge pull request #643 from wcc526/master
Update process_linux.go for Add process ConnectionsMax
2019-02-23 21:23:09 +01:00
wcc526 462e0f6c2f Update process_linux.go for Add process ConnectionsMax 2019-02-23 18:55:31 +08:00
David Naylor 414c76f159 [process][linux] Export process page fault info
Add a function for retrieving page fault counts from /proc/[pid]/stat on
Linux.
2018-12-13 16:19:40 -08:00
Lomanic 8ffa453390 #596 Amend last commit, add missing strconv pkg in process_freebsd.go 2018-11-17 18:27:04 +01:00
Lomanic 8ef9b01052 Fix process.Foreground for BSDs, add openbsd implementation 2018-11-11 19:05:34 +01:00
Lomanic 878e0a701b Fix #596 Implement process.Background and process.Foreground functions 2018-11-08 20:52:01 +01:00
shirou 145dca90f7 change to use CommandContext. 2018-03-31 21:35:53 +09:00
shirou 6a368fb7cd [process]: add ProcessesWithContext. 2018-01-11 11:47:13 +09:00
shirou cd61c36c4f
Merge branch 'master' into feature/add_context_support 2018-01-09 11:18:25 +09:00
Nick Kirsch 6c35887d02 Add ErrNotImplementedError to Darwin, FreeBSD, and OpenBSD. 2018-01-04 11:51:49 -08:00
shirou 4c73494c78 Add WithContext functions. 2017-12-31 15:25:49 +09:00
Sam Kleinman 4d92a03da8 fix cross compiles 2017-11-09 10:31:12 -05:00
tycho garen 08a382b207 make process.processes function public 2017-11-05 20:40:33 -05:00
Leonid Podolny 7ee4a4c6ff Fix Threads() signature to better match python original 2017-10-04 15:38:01 -04:00
Leonid Podolny 7ad3836ad3 Implement Threads() for Linux 2017-10-04 15:38:01 -04:00
shirou a452de7c73 Merge pull request #346 from phemmer/rlimit-current
add current values to rlimit retrieval
2017-08-31 11:58:10 +09:00
Sean Chittenden 635b971c0e
Move from the `syscall` package to the `golang.org/x/sys/{unix,windows}` 2017-06-02 13:51:00 -07:00
Patrick Hemmer 60c32eb847 add current values to rlimit retrieval 2017-06-01 16:38:44 -04:00
Shirou WAKAYAMA 613a8a90e1 fixed by golint. 2016-04-01 21:34:39 +09:00
Shirou WAKAYAMA da89408631 Merge branch 'master' into v2 2016-03-31 18:08:24 +09:00
WAKAYAMA shirou 37d8908841 [process]freebsd: implementes proceess.Nice() 2016-03-31 17:34:09 +09:00
WAKAYAMA shirou 37b6b4051f [process]freebsd: process_freebsd_amd64.go is now generated by cgo godefs. 2016-03-31 17:19:49 +09:00
Shirou WAKAYAMA 46ddd57c72 process has NetIOCounters and IOCounters. 2016-03-22 23:23:08 +09:00
Shirou WAKAYAMA ea152ea901 [BREAKING CHANGE] rename functions to pass golint. ex) net.NetIOCounters -> net.IOCounters 2016-03-22 23:09:12 +09:00
Chris Gilling d098bf135f process: fix bug in CmdlineSlice where cmdline is empty
Sometimes (at least on linux) cmdline is empty, this was causing
a panic.
2016-02-27 18:29:24 -08:00
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.
2016-02-27 18:01:49 -08:00
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.
2016-02-16 20:22:04 +01:00
WAKAYAMA shirou 0af91ba32b [disk,process]freebsd: binary.go moved to internal. 2016-02-12 23:10:40 +09:00
Shirou WAKAYAMA d680853370 net,process[linux]: add process.NetIOCounter and net.NetIOCounterByFile. 2016-01-21 17:31:05 +09:00
Masayoshi Sekimura 3a1fa5dc80 format go program with go 1.5.2 "go fmt" 2016-01-09 16:17:21 -08:00
Nikolay Sivko 45dcaa3b91 process[freebsd]: Cmdline, IOCounters, CPUTimes implemented 2015-11-24 17:43:31 +03:00
Shirou WAKAYAMA dd13300833 process[linux,freebsd,darwin]: implements Children using pgrep. 2015-11-24 00:04:20 +09:00
Shirou WAKAYAMA 7288e9a5af common[all]: add internal 2015-10-20 00:04:57 +09:00