February 2018
Intermediate to advanced
340 pages
9h 43m
English
package main import ( "fmt" "os" "os/signal" "syscall" ) func main() { // Create the channel where the received // signal would be sent. The Notify // will not block when the signal // is sent and the channel is not ready. // So it is better to // create buffered channel. sChan := make(chan os.Signal, 1) // Notify will catch the // given signals and send // the os.Signal value // through the sChan. // If no signal specified in // argument, all signals are matched. signal.Notify(sChan, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT) // Create channel to wait till theRead now
Unlock full access