From 58e22f7a9cd002518b489690d41e5bb38fbabb8f Mon Sep 17 00:00:00 2001 From: dnomd343 Date: Sat, 3 Sep 2022 21:31:53 +0800 Subject: [PATCH] update: remove glib main loop --- src/process.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/process.c b/src/process.c index 65bdcf8..d78b6a0 100644 --- a/src/process.c +++ b/src/process.c @@ -1,7 +1,9 @@ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif -#include +//#include +#include +#include #include #include #include @@ -22,6 +24,7 @@ char **plugin_env; char *plugin_arg[] = { NULL, NULL }; int exiting = 0; +int exit_complete = 0; typedef struct exit_info { int pid; @@ -29,7 +32,7 @@ typedef struct exit_info { int exit_signal; } exit_info; -GMainLoop* main_loop; +//GMainLoop* main_loop; pid_t ss_pid = 0, plugin_pid = 0; void show_params(); @@ -96,7 +99,8 @@ void get_sub_exit() { // catch child process die exit_with_child(); } } - g_main_loop_quit(main_loop); // exit main loop +// g_main_loop_quit(main_loop); // exit main loop + exit_complete = 1; } void plugin_env_load() { // load plugin's environment variable @@ -197,7 +201,7 @@ void show_params() { // show shadowsocks and plugin params void start_bootstrap(char *ss_type, int is_udp_proxy) { // start shadowsocks and plugin (optional) show_params(); - main_loop = g_main_loop_new(NULL, FALSE); +// main_loop = g_main_loop_new(NULL, FALSE); signal(SIGINT, exit_with_child); // catch Ctrl + C (2) signal(SIGTERM, exit_with_child); // catch exit signal (15) signal(SIGCHLD, get_sub_exit); // callback when child process die @@ -227,6 +231,12 @@ void start_bootstrap(char *ss_type, int is_udp_proxy) { // start shadowsocks and } else { printf("[Shadowsocks Bootstrap] UDP Proxy no need.\n"); } - g_main_loop_run(main_loop); // into main loop for wait + + while (!exit_complete) { + pause(); + printf("!!! get signal !!!\n"); + } + +// g_main_loop_run(main_loop); // into main loop for wait exit_with_child(); }