Skip to content

Commit

Permalink
Merge pull request #1814 from gravitational/dmitri/sigint-default-2.4.x
Browse files Browse the repository at this point in the history
2.4.x: avoid resetting the SIGINT handler unconditionally
  • Loading branch information
a-palchikov authored Mar 26, 2018
2 parents 46e3079 + a458a82 commit e69b96c
Showing 1 changed file with 17 additions and 3 deletions.
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)
}
}

0 comments on commit e69b96c

Please sign in to comment.