Where can I find Go runtime goroutines spec?

66 Views Asked by At

After running a rather simple Go program:

package main

import (
    "fmt"
    "os"
    "os/signal"
    "syscall"
)

func main() {
    sigs := make(chan os.Signal)

    signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)

    fmt.Printf("awaiting signal at %d\n", os.Getpid())
    <-sigs
    fmt.Printf("\nexiting\n")
}

I can observe the following threads being created on my system (found by top -H to list threads aside processes):

 3949 USER    20   0    3232   1400   1032 S  0.0  0.0   0:00.00 goroutines1
 3950 USER    20   0    3232   1400   1032 S  0.0  0.0   0:00.00 goroutines1
 3951 USER    20   0    3232   1400   1032 S  0.0  0.0   0:00.00 goroutines1
 3952 USER    20   0    3232   1400   1032 S  0.0  0.0   0:00.00 goroutines1
 3953 USER    20   0    3232   1400   1032 S  0.0  0.0   0:00.00 goroutines1

Where PID 3949 is the main thread.

Where can I find the spec/information about the other 4 threads being run by Go runtime?

0

There are 0 best solutions below