From 8294f67566ebefb55e9659ff6ad7049c873335ce Mon Sep 17 00:00:00 2001 From: Lomanic Date: Thu, 27 Dec 2018 21:23:47 +0100 Subject: [PATCH] [host][openbsd] Remove external calls to uname in PlatformInformation() --- host/host_openbsd.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/host/host_openbsd.go b/host/host_openbsd.go index 2ad64d7..bb16fca 100644 --- a/host/host_openbsd.go +++ b/host/host_openbsd.go @@ -8,7 +8,6 @@ import ( "encoding/binary" "io/ioutil" "os" - "os/exec" "runtime" "strconv" "strings" @@ -17,6 +16,7 @@ import ( "github.com/shirou/gopsutil/internal/common" "github.com/shirou/gopsutil/process" + "golang.org/x/sys/unix" ) const ( @@ -108,19 +108,14 @@ func PlatformInformationWithContext(ctx context.Context) (string, string, string platform := "" family := "" version := "" - uname, err := exec.LookPath("uname") - if err != nil { - return "", "", "", err - } - out, err := invoke.CommandWithContext(ctx, uname, "-s") + p, err := unix.Sysctl("kern.ostype") if err == nil { - platform = strings.ToLower(strings.TrimSpace(string(out))) + platform = strings.ToLower(p) } - - out, err = invoke.CommandWithContext(ctx, uname, "-r") + v, err := unix.Sysctl("kern.osrelease") if err == nil { - version = strings.ToLower(strings.TrimSpace(string(out))) + version = strings.ToLower(v) } return platform, family, version, nil