Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.4.x: avoid resetting the SIGINT handler unconditionally #1814

Merged
merged 2 commits into from
Mar 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions lib/utils/signal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@ package utils

/*
#include <signal.h>
void resetInterruptSignalHandler() {
signal(SIGINT, SIG_DFL);
int resetInterruptSignalHandler() {
struct sigaction act;
int result;
if ((result = sigaction(SIGINT, 0, &act)) != 0) {
return result;
}
if (act.sa_handler == SIG_IGN) {
// Reset the handler for SIGINT to system default.
// FIXME: Note, this will also overwrite runtime's signal handler
signal(SIGINT, SIG_DFL);
}
return 0;
}
*/
import "C"
import log "github.com/sirupsen/logrus"

// ResetInterruptSignal will reset the handler for SIGINT back to the default
// handler. We need to do this because when sysvinit launches Teleport on some
Expand All @@ -16,5 +27,8 @@ import "C"
// http://garethrees.org/2015/08/07/ping/
// https://github.com/openssh/openssh-portable/commit/4e0f5e1ec9b6318ef251180dbca50eaa01f74536
func ResetInterruptSignalHandler() {
C.resetInterruptSignalHandler()
result := C.resetInterruptSignalHandler()
if result != 0 {
log.Warnf("Failed to reset interrupt signal handler: %v.", result)
}
}