ADVERTISEMENT
ADVERTISEMENT

How to get the parent process identification using syscall in Golang?

Here, we will learn to get the parent process identification using syscall in Golang.
Submitted by IncludeHelp, on November 13, 2021

In the Go programming language, to get the parent process identification using syscall – we use the Getppid() function of the syscall package. The Getppid() function returns the process ID of the parent of the calling process.

Syntax:

func Getpid() (pid int)

Consider the below example demonstrating how to get the parent process identification using syscall in Golang?

package main

import (
	"fmt"
	"syscall"
)

func main() {
	// Using the Getpid(),
	// Getting the parent process ID
	pid := syscall.Getgid()

	// Printing the parent process ID
	fmt.Println("parent process ID:", pid)
}

Output

parent process ID: 14022

Golang syscall Package Programs »



ADVERTISEMENT




ADVERTISEMENT



Comments and Discussions!

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.