Add a signal handler to pause.

It returns 0 when a signal is received.
This commit is contained in:
Victor Marmol
2014-10-03 08:36:08 -07:00
parent f9e5477e2b
commit 9b747c3a9d
2 changed files with 15 additions and 3 deletions

View File

@@ -18,9 +18,16 @@ limitations under the License.
package main
import "syscall"
import (
"os"
"os/signal"
"syscall"
)
func main() {
// Halts execution, waiting on signal.
syscall.Pause()
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill, syscall.SIGTERM)
// Block until a signal is received.
<-c
}