Hi, >Interesting. When you press the disconnect button openconnect-gui >sends the detach command to libopenconnect which should have ran the >script. Isn't that the case? Sorry about that I hadn't explained it well. In fact,I am testing the openconnect of command line version in git(not gui)(I need the console client). ? I mean that , at the ? line 1309 of the main.c , didn't set the signal handler on Windows. so, I try to modify it like below , but It does not work ( I hope that the?console client can receive the kill signal sended by another process). diff --git a/main.c b/main.cindex df57698..753b24a 100644 --- a/main.c +++ b/main.c @@ -47,6 +47,8 @@ #include "openconnect-internal.h" #ifdef _WIN32 +#include <signal.h> +#include <winsock2.h> #include <shlwapi.h> #include <wtypes.h> #include <wincon.h> @@ -668,6 +670,30 @@ static void set_default_vpncscript(void) default_vpncscript = "cscript " DEFAULT_VPNCSCRIPT; } } + +static void handle_signal_windows(int sig) +{ + char cmd=-1; + + switch (sig) { + case SIGINT://interrupt(Ctrl+C) + case SIGTERM://Software termination signal from kill + case SIGABRT://abnormal termination triggered by abort call(Abort) + cmd = OC_CMD_CANCEL; + break; + case SIGFPE: + case SIGILL: + case SIGSEGV: + default: + return; + //cmd = OC_CMD_PAUSE; + //break; + } + + if (send(sig_cmd_fd, &cmd, 1,0) < 0) { + /* suppress warn_unused_result */ + } +} #endif static void usage(void) @@ -1292,6 +1318,10 @@ int main(int argc, char **argv) sigaction(SIGINT, &sa, NULL); sigaction(SIGHUP, &sa, NULL); sigaction(SIGUSR2, &sa, NULL); +#else + signal(SIGINT, handle_signal_windows); + signal(SIGTERM, handle_signal_windows); + signal(SIGABRT, handle_signal_windows); #endif /* !_WIN32 */ sig_cmd_fd = openconnect_setup_cmd_pipe(vpninfo); thanks, xiao guang