mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-14 12:20:27 +08:00
安装过程中可以选择自动在本机安装MySQL
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
ProcDir = "/proc"
|
||||
)
|
||||
|
||||
func FindPidWithName(name string) int {
|
||||
// process name
|
||||
commFiles, err := filepath.Glob(ProcDir + "/*/comm")
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
for _, commFile := range commFiles {
|
||||
data, err := os.ReadFile(commFile)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if strings.TrimSpace(string(data)) == name {
|
||||
var pieces = strings.Split(commFile, "/")
|
||||
var pid = pieces[len(pieces)-2]
|
||||
pidInt, _ := strconv.Atoi(pid)
|
||||
return pidInt
|
||||
}
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
Reference in New Issue
Block a user