Created
January 22, 2015 19:35
-
-
Save vaskoz/46cf1973a8d4b5945dc7 to your computer and use it in GitHub Desktop.
Golang CPU bomb - actually prevents the main thread from getting scheduled to run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"os/signal" | |
"runtime" | |
"syscall" | |
) | |
func main() { | |
numOfProcessors := runtime.NumCPU() | |
runtime.GOMAXPROCS(numOfProcessors) | |
for i := 0; i < numOfProcessors; i++ { | |
go func() { | |
for { | |
} | |
}() | |
} | |
sigChan := make(chan os.Signal, 1) | |
signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL) | |
sig := <-sigChan | |
fmt.Println(sig) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment