From 2bf011cb3db60d87ba790fc6228debe4f68a76c1 Mon Sep 17 00:00:00 2001 From: Russell Jones Date: Wed, 24 May 2017 10:31:05 -0700 Subject: [PATCH] Fix ^C ignored issue on CentOS 6.8. --- lib/service/service.go | 3 +++ lib/utils/signal.go | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 lib/utils/signal.go diff --git a/lib/service/service.go b/lib/service/service.go index f1665adf98713..20b29377850ab 100644 --- a/lib/service/service.go +++ b/lib/service/service.go @@ -185,6 +185,9 @@ func (process *TeleportProcess) connectToAuthService(role teleport.Role) (*Conne // NewTeleport takes the daemon configuration, instantiates all required services // and starts them under a supervisor, returning the supervisor object func NewTeleport(cfg *Config) (*TeleportProcess, error) { + // before we do anything reset the SIGINT handler back to the default + utils.ResetInterruptSignalHandler() + if err := validateConfig(cfg); err != nil { return nil, trace.Wrap(err, "Configuration error") } diff --git a/lib/utils/signal.go b/lib/utils/signal.go new file mode 100644 index 0000000000000..3f86009629205 --- /dev/null +++ b/lib/utils/signal.go @@ -0,0 +1,20 @@ +package utils + +/* +#include +void resetInterruptSignalHandler() { +signal(SIGINT, SIG_DFL); +} +*/ +import "C" + +// ResetInterruptSignal will reset the handler for SIGINT back to the default +// handler. We need to do this because when sysvinit launches Teleport on some +// operating systems (like CentOS 6.8) it configures Teleport to ignore SIGINT +// signals. See the following for more details: +// +// http://garethrees.org/2015/08/07/ping/ +// https://github.com/openssh/openssh-portable/commit/4e0f5e1ec9b6318ef251180dbca50eaa01f74536 +func ResetInterruptSignalHandler() { + C.resetInterruptSignalHandler() +}