diff --git a/src/hev-main.c b/src/hev-main.c index 3a5258c..e551186 100644 --- a/src/hev-main.c +++ b/src/hev-main.c @@ -8,6 +8,7 @@ */ #include +#include #include @@ -33,6 +34,12 @@ show_help (const char *self_path) MICRO_VERSION, COMMIT_ID); } +static void +sigint_handler (int signum) +{ + hev_socks5_tunnel_stop (); +} + int hev_socks5_tunnel_main (const char *config_path, int tun_fd) { @@ -103,6 +110,8 @@ main (int argc, char *argv[]) return -1; } + signal (SIGINT, sigint_handler); + res = hev_socks5_tunnel_main (argv[1], -1); if (res < 0) return -2; diff --git a/src/hev-socks5-tunnel.c b/src/hev-socks5-tunnel.c index 420f61e..2748c16 100644 --- a/src/hev-socks5-tunnel.c +++ b/src/hev-socks5-tunnel.c @@ -57,12 +57,6 @@ static HevTask *task_lwip_io; static HevTask *task_lwip_timer; static HevList session_set; -static void -sigint_handler (int signum) -{ - hev_socks5_tunnel_stop (); -} - static int task_io_yielder (HevTaskYieldType type, void *data) { @@ -509,13 +503,6 @@ lwip_timer_task_fini (void) } } -static void -signal_init (void) -{ - signal (SIGPIPE, SIG_IGN); - signal (SIGINT, sigint_handler); -} - int hev_socks5_tunnel_init (int tun_fd) { @@ -543,7 +530,7 @@ hev_socks5_tunnel_init (int tun_fd) if (res < 0) goto exit; - signal_init (); + signal (SIGPIPE, SIG_IGN); hev_task_mutex_init (&mutex);