Standard library / os
os.Getppid()
Returns the parent process ID; parent relationships may change during execution. Example intended for Linux/AMD64 with Go 1.23.2 in a disposable working directory; other platforms may differ. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func Getppid() intReturn Value
int
Returns the parent process ID; parent relationships may change during execution.
Working Example
Example Snippetgo
package main
import ( "fmt" "os")
func must(e error) { if e != nil { panic(e) }}func main() { fmt.Println(os.Getppid() > 0) }