diff --git a/process/process_linux.go b/process/process_linux.go index df6c1401f..d5b5bc329 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -688,9 +688,9 @@ func (p *Process) fillSliceFromCmdlineWithContext(ctx context.Context) ([]string if len(cmdline) == 0 { return nil, nil } - if cmdline[len(cmdline)-1] == 0 { - cmdline = cmdline[:len(cmdline)-1] - } + + cmdline = bytes.TrimRight(cmdline, "\x00") + parts := bytes.Split(cmdline, []byte{0}) var strParts []string for _, p := range parts {