From c6f76accec87aa8f26084be4736fc68299db9ba0 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Fri, 20 Mar 2015 16:22:35 +0100 Subject: [PATCH] SIGTERM gracefully terminates the program Signed-off-by: Nikos Mavrogiannopoulos --- main.c | 2 ++ openconnect.8.in | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 5b93feb..990a4ee 100644 --- a/main.c +++ b/main.c @@ -663,6 +663,7 @@ static void handle_signal(int sig) switch (sig) { case SIGINT: + case SIGTERM: cmd = OC_CMD_CANCEL; break; case SIGHUP: @@ -1351,6 +1352,7 @@ int main(int argc, char **argv) sa.sa_handler = handle_signal; sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); sigaction(SIGHUP, &sa, NULL); sigaction(SIGUSR2, &sa, NULL); #endif /* !_WIN32 */ diff --git a/openconnect.8.in b/openconnect.8.in index c8f26d2..cbcece2 100644 --- a/openconnect.8.in +++ b/openconnect.8.in @@ -486,7 +486,7 @@ if this code is not executable on the local machine. .SH SIGNALS In the data phase of the connection, the following signals are handled: .TP -.B SIGINT +.B SIGINT, SIGTERM performs a clean shutdown by logging the session off, disconnecting from the gateway, and running the vpnc\-script to restore the network configuration. .TP @@ -499,7 +499,7 @@ session off; this allows for reconnection later using forces an immediate disconnection and reconnection; this can be used to quickly recover from LAN IP address changes. .TP -.B SIGTERM +.B SIGKILL exits immediately without logging off or running vpnc\-script. .SH LIMITATIONS Note that although IPv6 has been tested on all platforms on which -- 2.1.0