我想使用 Golang for Linux os 从特定子进程 id (pid) 获取父进程 id (ppid)
我有这段代码,它提供当前进程的 ppid 和 pid,但我想检索我指定的子进程的 ppid,而不是当前进程。
package main
import (
"fmt"
"os"
)
func main() {
pid := os.Getpid()
parentpid := os.Getppid()
fmt.Printf("The parent process id of %v is %v\n", pid, parentpid)
}
有没有办法像这样传递 pidos.Getppid(pid)或任何其他方法来检索 Golang 中指定 pid 的 ppid ?
慕娘9325324
繁星coding
相关分类