Created
March 31, 2015 21:42
-
-
Save slawosz/00fe027fa87559579a96 to your computer and use it in GitHub Desktop.
Go signals
This file contains hidden or 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" | |
"syscall" | |
) | |
func main() { | |
// Set up channel on which to send signal notifications. | |
// We must use a buffered channel or risk missing the signal | |
// if we're not ready to receive when the signal is sent. | |
fmt.Println("Got pid:", os.Getpid()) | |
c := make(chan os.Signal, 1) | |
signal.Notify(c, syscall.SIGUSR1) | |
// Block until a signal is received. | |
s := <-c | |
fmt.Println("Got signal:", s) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment