Skip to content

Commit

Permalink
HevSocks5Tunnel: Move SIGINT to main.
Browse files Browse the repository at this point in the history
  • Loading branch information
heiher committed Feb 15, 2024
1 parent 1cdc1ca commit 48e090a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
9 changes: 9 additions & 0 deletions src/hev-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

#include <stdio.h>
#include <signal.h>

#include <lwip/init.h>

Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 1 addition & 14 deletions src/hev-socks5-tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 48e090a

Please sign in to comment.