diff --git a/pkg/util/interrupt/child.go b/pkg/util/interrupt/child.go deleted file mode 100644 index f1565308a13..00000000000 --- a/pkg/util/interrupt/child.go +++ /dev/null @@ -1,26 +0,0 @@ -// +build !linux - -/* -Copyright 2016 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package interrupt - -import ( - "os" -) - -// childSignals are the allowed signals that can be sent to children in Windows to terminate -var childSignals = []os.Signal{os.Interrupt} diff --git a/pkg/util/interrupt/child_linux.go b/pkg/util/interrupt/child_linux.go deleted file mode 100644 index 35de11ad977..00000000000 --- a/pkg/util/interrupt/child_linux.go +++ /dev/null @@ -1,27 +0,0 @@ -// +build linux - -/* -Copyright 2016 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package interrupt - -import ( - "os" - "syscall" -) - -// childSignals are the allowed signals that can be sent to children in Unix variant OS's -var childSignals = []os.Signal{syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT} diff --git a/pkg/util/interrupt/interrupt.go b/pkg/util/interrupt/interrupt.go index 6f81cbda0e0..0f4da7d4cbf 100644 --- a/pkg/util/interrupt/interrupt.go +++ b/pkg/util/interrupt/interrupt.go @@ -20,8 +20,13 @@ import ( "os" "os/signal" "sync" + "syscall" ) +// terminationSignals are signals that cause the program to exit in the +// supported platforms (linux, darwin, windows). +var terminationSignals = []os.Signal{syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT} + // Handler guarantees execution of notifications after a critical section (the function passed // to a Run method), even in the presence of process termination. It guarantees exactly once // invocation of the provided notify functions. @@ -82,7 +87,7 @@ func (h *Handler) Signal(s os.Signal) { // per Handler instance, so calling Run more than once will not behave as the user expects. func (h *Handler) Run(fn func() error) error { ch := make(chan os.Signal, 1) - signal.Notify(ch, childSignals...) + signal.Notify(ch, terminationSignals...) defer func() { signal.Stop(ch) close(ch)