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

How 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> 

Similar Posts

  • C++ Reference and Styles

    C++ References Reference of the C++ Language Library, with detailed descriptions of its elements and examples on how to use its functions: http://www.cplusplus.com/reference/ C++ reference: http://www.cppreference.com/w/ C++ Styles I compile a list of C++ styles on the Internet. http://geosoft.no/development/cppstyle.html http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml http://www.mactech.com/articles/develop/issue_02/C%2B%2B_Style_Guide_v007.html http://www.cs.uga.edu/~dkl/1302/Fall99/style.html Read more: GNU C Reference Manual Reference: Special HTML Characters How to generate…

  • What is Double-Blind review for a paper?

    I want to submit my paper to NAS 2015 but I am confused about its double-blind review 盲审又包括单盲审(Single-Blind Peer Review, SBPR)和双盲审(Double-Blind Peer Review, DBPR)。双盲审是审者与作者之间互相都不知道彼此身份的匿名评审。在双盲审的过程中,中间组织者的规范和保密工作很重要。单盲审一般是审者知道作者的身份,而作者不知道审者是谁。 计算机有不少会议实行双盲评审。 Reference: http://emuch.net/html/201104/3022021.html Read more: When should the authors anonymize themselves in a paper submitted to a conference for review? How to write paper reviews? How to convert A4 paper format…

  • | |

    Installing Zlib from Source Code in Ubuntu Linux

    Zlib is a widely-used open-source compression library that implements the DEFLATE algorithm. It underpins gzip, PNG, HTTP compression, and countless software packages. While Ubuntu’s package manager provides a ready-to-use zlib, building from source gives you the latest version, the ability to set a custom install prefix, and full control over compile-time options. This guide covers…

Leave a Reply

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