Menu Close

Go – How to get the process id of the parent of caller in go

Here, We will learn how to get the process id of the parent of caller in go. We can do it by using Getppid() function in os package in go golang.

Function prototype:

func Getppid() int

Return value:

Getppid() function in os package returns 
the process id of the caller's parent.

Example with code:

package main

import "fmt"
import "os"


func main() {

  pid := os.Getppid()

  fmt.Println(pid)

}

Output:

1423

To learn more about golang, Please refer given below link:

https://www.techieindoor.com/go-lang-tutorial/

References:

https://golang.org/doc/
https://golang.org/pkg/
Posted in golang, os

Leave a Reply

Your email address will not be published. Required fields are marked *