mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Add a signal handler to pause.
It returns 0 when a signal is received.
This commit is contained in:
parent
f9e5477e2b
commit
9b747c3a9d
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user