lengyijun
3/19/2018 - 7:40 AM

golang pid

golang pid

package main

import (
    "fmt"
    "os"
    "time"
)

func main() {
    pid := os.Getpid()
    fmt.Println(pid)
    fetchDemo()
    fmt.Println("the main function is executed")
}

func fetchDemo() {
    pid := os.Getpid()
    fmt.Println(pid)
    ppid := os.Getppid()
    fmt.Println(ppid)
    time.Sleep(10 * time.Minute)
}

the output is

21440
21440
21416