We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 953146a commit 72372edCopy full SHA for 72372ed
1 file changed
internal/utils/executil/exec.go
@@ -20,6 +20,8 @@ import (
20
"path/filepath"
21
"runtime"
22
23
+ "huatuo-bamai/internal/procfs"
24
+
25
"golang.org/x/sys/unix"
26
)
27
@@ -34,7 +36,7 @@ func RunningDir() (string, error) {
34
36
35
37
func HostnameByPid(pid uint32) (string, error) {
38
var empty string
- fd, err := os.Open(fmt.Sprintf("/proc/%d/ns/uts", pid))
39
+ fd, err := os.Open(procfs.Path(fmt.Sprintf("%d", pid), "ns/uts"))
40
if err != nil {
41
return empty, err
42
}
@@ -50,7 +52,7 @@ func HostnameByPid(pid uint32) (string, error) {
50
52
51
53
54
func ProcNameByPid(pid uint32) (string, error) {
- data, err := os.ReadFile(fmt.Sprintf("/proc/%d/cmdline", pid))
55
+ data, err := os.ReadFile(procfs.Path(fmt.Sprintf("%d", pid), "cmdline"))
56
57
return "", err
58
0 commit comments