| | |
| | | |
| | | 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"); |