diff --git a/process/process_freebsd.go b/process/process_freebsd.go index 4989867..3242ff6 100644 --- a/process/process_freebsd.go +++ b/process/process_freebsd.go @@ -77,6 +77,9 @@ func (p *Process) CmdlineSlice() ([]string, error) { if err != nil { return nil, err } + if len(buf) == 0 { + return nil, nil + } if buf[len(buf)-1] == 0 { buf = buf[:len(buf)-1] } diff --git a/process/process_linux.go b/process/process_linux.go index 7c6bb29..2bb003e 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -421,6 +421,9 @@ func (p *Process) fillSliceFromCmdline() ([]string, error) { if err != nil { return nil, err } + if len(cmdline) == 0 { + return nil, nil + } if cmdline[len(cmdline)-1] == 0 { cmdline = cmdline[:len(cmdline)-1] }