mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
优化node启动
This commit is contained in:
25
util/sysprocess/process.go
Normal file
25
util/sysprocess/process.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package sysprocess
|
||||
|
||||
import (
|
||||
"github.com/shirou/gopsutil/process"
|
||||
"os"
|
||||
)
|
||||
|
||||
func GetProcessNameByPID(pid int32) (string, error) {
|
||||
proc, err := process.NewProcess(pid)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
processName, err := proc.Name()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return processName, nil
|
||||
}
|
||||
|
||||
func GetMyProcessName() (string, error) {
|
||||
return GetProcessNameByPID(int32(os.Getpid()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user