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 package main
import "syscall" import (
"os"
"os/signal"
"syscall"
)
func main() { func main() {
// Halts execution, waiting on signal. c := make(chan os.Signal, 1)
syscall.Pause() signal.Notify(c, os.Interrupt, os.Kill, syscall.SIGTERM)
// Block until a signal is received.
<-c
} }

View File

@ -3,4 +3,9 @@
set -e set -e
set -x set -x
# Build the binary.
go build --ldflags '-extldflags "-static" -s' pause.go go build --ldflags '-extldflags "-static" -s' pause.go
# Run goupx to shrink binary size.
go get github.com/pwaller/goupx
goupx pause