From a8418dfd73098a842e15bc2747dfcd25c9aadac0 Mon Sep 17 00:00:00 2001 From: Chris Gianelloni Date: Thu, 9 Nov 2023 18:19:10 -0500 Subject: [PATCH] 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 --- README.md | 2 +- process/process_freebsd.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 78751d72f..2cbdc71a3 100644 --- a/README.md +++ b/README.md @@ -190,7 +190,7 @@ Some code is ported from Ohai. Many thanks. |users |x |x |x |x |x | | | |pids |x |x |x |x |x | | | |pid\_exists |x |x |x |x |x | | | -|net\_connections |x | |x |x | | | | +|net\_connections |x |x |x |x | | | | |net\_protocols |x | | | | | | | |net\_if\_addrs | | | | | | | | |net\_if\_stats | | | | | | | | diff --git a/process/process_freebsd.go b/process/process_freebsd.go index 85134b7ee..40b10e14f 100644 --- a/process/process_freebsd.go +++ b/process/process_freebsd.go @@ -286,11 +286,11 @@ func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) { } func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) { - return nil, common.ErrNotImplementedError + return net.ConnectionsPidWithContext(ctx, "all", p.Pid) } func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error) { - return nil, common.ErrNotImplementedError + return net.ConnectionsPidMaxWithContext(ctx, "all", p.Pid, max) } func ProcessesWithContext(ctx context.Context) ([]*Process, error) {