I want to get parent process id (ppid) from specific child process id (pid) using Golang for Linux os
I have this code which gives ppid and pid of the current process but I want to retrieve ppid of the child process which I specify and not the current process.
package main
import (
"fmt"
"os"
)
func main() {
pid := os.Getpid()
parentpid := os.Getppid()
fmt.Printf("The parent process id of %v is %v
", pid, parentpid)
}
Is there a way to pass pid like this os.Getppid(pid)
or any other method to retrieve ppid of specified pid in Golang?