Fix: should split linux process name with space (#2008)
This commit is contained in:
parent
b52d0c16e9
commit
83bfe521b1
1 changed files with 9 additions and 16 deletions
|
@ -9,7 +9,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"unicode"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/Dreamacro/clash/common/pool"
|
"github.com/Dreamacro/clash/common/pool"
|
||||||
|
@ -219,24 +221,15 @@ func resolveProcessNameByProcSearch(inode, uid int) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func splitCmdline(cmdline []byte) string {
|
func splitCmdline(cmdline []byte) string {
|
||||||
indexOfEndOfString := len(cmdline)
|
idx := bytes.IndexFunc(cmdline, func(r rune) bool {
|
||||||
|
return unicode.IsControl(r) || unicode.IsSpace(r)
|
||||||
|
})
|
||||||
|
|
||||||
for i, c := range cmdline {
|
return filepath.Base(string(cmdline[:idx]))
|
||||||
if c == 0 {
|
|
||||||
indexOfEndOfString = i
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return filepath.Base(string(cmdline[:indexOfEndOfString]))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func isPid(s string) bool {
|
func isPid(s string) bool {
|
||||||
for _, s := range s {
|
return strings.IndexFunc(s, func(r rune) bool {
|
||||||
if s < '0' || s > '9' {
|
return !unicode.IsDigit(r)
|
||||||
return false
|
}) == -1
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue