process: fix bug in CmdlineSlice where cmdline is empty
Sometimes (at least on linux) cmdline is empty, this was causing a panic.
This commit is contained in:
parent
b8c40ac83c
commit
d098bf135f
|
@ -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]
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue