From a377c5114a7a0786e2443dfa53187effacce1af5 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Mon, 12 Mar 2018 02:53:58 -0700 Subject: [PATCH] Fix #1974 --- src/local.c | 9 ++++++--- src/redir.c | 7 +++++-- src/server.c | 7 +++++-- src/tunnel.c | 7 +++++-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/local.c b/src/local.c index 6b04f098..03a154ff 100644 --- a/src/local.c +++ b/src/local.c @@ -102,6 +102,7 @@ static int ipv6first = 0; static int fast_open = 0; static int no_delay = 0; static int udp_fd = 0; +static int ret_val = 0; static struct ev_signal sigint_watcher; static struct ev_signal sigterm_watcher; @@ -1296,8 +1297,10 @@ signal_cb(EV_P_ ev_signal *w, int revents) switch (w->signum) { #ifndef __MINGW32__ case SIGCHLD: - if (!is_plugin_running()) + if (!is_plugin_running()) { LOGE("plugin service exit unexpectedly"); + ret_val = -1; + } else return; case SIGUSR1: @@ -1820,7 +1823,7 @@ main(int argc, char **argv) winsock_cleanup(); #endif - return 0; + return ret_val; } #else @@ -1969,7 +1972,7 @@ _start_ss_local_server(profile_t profile, ss_local_callback callback, void *udat winsock_cleanup(); #endif - return 0; + return ret_val; } int diff --git a/src/redir.c b/src/redir.c index bb7abe72..c4aef0bd 100644 --- a/src/redir.c +++ b/src/redir.c @@ -96,6 +96,7 @@ static int nofile = 0; #endif static int fast_open = 0; static int no_delay = 0; +static int ret_val = 0; static struct ev_signal sigint_watcher; static struct ev_signal sigterm_watcher; @@ -819,8 +820,10 @@ signal_cb(EV_P_ ev_signal *w, int revents) if (revents & EV_SIGNAL) { switch (w->signum) { case SIGCHLD: - if (!is_plugin_running()) + if (!is_plugin_running()) { LOGE("plugin service exit unexpectedly"); + ret_val = -1; + } else return; case SIGINT: @@ -1258,5 +1261,5 @@ main(int argc, char **argv) stop_plugin(); } - return 0; + return ret_val; } diff --git a/src/server.c b/src/server.c index fd9061a3..ff46fdd9 100644 --- a/src/server.c +++ b/src/server.c @@ -122,6 +122,7 @@ static int mode = TCP_ONLY; static int ipv6first = 0; static int fast_open = 0; static int no_delay = 0; +static int ret_val = 0; #ifdef HAVE_SETRLIMIT static int nofile = 0; @@ -1495,8 +1496,10 @@ signal_cb(EV_P_ ev_signal *w, int revents) switch (w->signum) { #ifndef __MINGW32__ case SIGCHLD: - if (!is_plugin_running()) + if (!is_plugin_running()) { LOGE("plugin service exit unexpectedly"); + ret_val = -1; + } else return; #endif @@ -2069,5 +2072,5 @@ main(int argc, char **argv) winsock_cleanup(); #endif - return 0; + return ret_val; } diff --git a/src/tunnel.c b/src/tunnel.c index fc9be825..d2f6afcb 100644 --- a/src/tunnel.c +++ b/src/tunnel.c @@ -96,6 +96,7 @@ static int mode = TCP_ONLY; static int nofile = 0; #endif static int no_delay = 0; +static int ret_val = 0; static struct ev_signal sigint_watcher; static struct ev_signal sigterm_watcher; @@ -745,8 +746,10 @@ signal_cb(EV_P_ ev_signal *w, int revents) switch (w->signum) { #ifndef __MINGW32__ case SIGCHLD: - if (!is_plugin_running()) + if (!is_plugin_running()) { LOGE("plugin service exit unexpectedly"); + ret_val = -1; + } else return; #endif @@ -1197,5 +1200,5 @@ main(int argc, char **argv) winsock_cleanup(); #endif - return 0; + return ret_val; }