Skip to content

Commit

Permalink
feat: use lsof for net_connections on FreeBSD
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
wolf31o2 committed Nov 9, 2023
1 parent e74324b commit a8418df
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | | | | | | | |
Expand Down
4 changes: 2 additions & 2 deletions process/process_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a8418df

Please sign in to comment.