How to get the running process' parent process' ID in Go?

How to get the running process' parent process' ID in Go?

asked Jun 5 by dtivl (2,500 points)

1 Answer

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: %d\n", os.Getppid())
ppid: 19824
12
nil
gore> 
answered Jun 5 by dtivl (2,500 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...