From 7590c43344e530e3085e494293959aca9cd7e17b Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期三, 23 十二月 2020 17:12:38 +0800 Subject: [PATCH] update --- test_net_socket/test_bus_stop.c | 41 ++++++++++++++++++++++------------------- 1 files changed, 22 insertions(+), 19 deletions(-) diff --git a/test_net_socket/test_bus_stop.c b/test_net_socket/test_bus_stop.c index ed2f60f..a1c20ec 100644 --- a/test_net_socket/test_bus_stop.c +++ b/test_net_socket/test_bus_stop.c @@ -8,42 +8,45 @@ static void * server_sockt; +static void sigint_handler(int sig) { + bus_server_socket_wrapper_close(server_sockt); +} + static void *_start_bus_(void *arg) { - // pthread_detach(pthread_self()); + pthread_detach(pthread_self()); printf("Start bus server\n"); pthread_t tid; - - server_sockt = bus_server_socket_wrapper_open(); if(bus_server_socket_wrapper_start_bus(server_sockt) != 0) { printf("start bus failed\n"); } + printf("============_start_bus_ end\n" ); } + int main() { - - pthread_t tid; char action[512]; - + signal(SIGINT, sigint_handler); shm_mm_wrapper_init(512); + server_sockt = bus_server_socket_wrapper_open(); pthread_create(&tid, NULL, _start_bus_, NULL); - while (true) { - printf("Input action: Close?\n"); - if(scanf("%s", action) < 1) { - printf("Invalide action\n"); - continue; - } + // while (true) { + // printf("Input action: Close?\n"); + // if(scanf("%s", action) < 1) { + // printf("Invalide action\n"); + // continue; + // } - if(strcmp(action, "close") == 0) { - bus_server_socket_wrapper_close(server_sockt); - break; - } else { - printf("Invalide action\n"); - } - } + // if(strcmp(action, "close") == 0) { + // bus_server_socket_wrapper_close(server_sockt); + // break; + // } else { + // printf("Invalide action\n"); + // } + // } if (pthread_join(tid, NULL) != 0) { perror(" pthread_join"); -- Gitblit v1.8.0