How to get the running process’ parent process’ ID in Go?
Posted on In QAHow to get the running process’ parent process’ ID in Go?
In Go, you may call the os.Getppid()
func from the os
package to get the parent process’ pid.
func Getppid() int
Getppid returns the process id of the caller's parent.
One example is as follows.
$ gore
gore version 0.2.6 :help for help
gore> :import "fmt"
gore> :import "os"
gore> fmt.Printf("ppid: %dn", os.Getppid())
ppid: 19824
12
nil
gore>