/** * \brief Callback function for handling signals. * \details Only SIGINT (Ctrl-C) is handled. When first SIGINT is received, * then client tries to terminate connection and it set handling to SIGINT * to default behavior (terminate application). * \param sig identifier of signal */ static void handle_signal(int sig) { if(sig == SIGINT) { printf("%s() try to terminate connection: %d\n", __FUNCTION__, session_id); vrs_send_connect_terminate(session_id); /* Reset signal handling to default behavior */ signal(SIGINT, SIG_DFL); } }
/** * \brief This function is callback function for receiving of command Node_Destroy * * It means, that this function is called, when verse_callback_update * is executed and there is any Node_Destroy command in incoming queue. * * \param[in] session_id The ID of session with some verse server * \param[in] node_id The ID of destroyed node */ static void cb_receive_node_destroy(const uint8_t session_id, const uint32_t node_id) { printf("%s() session_id: %d, node_id: %d\n", __FUNCTION__, session_id, node_id); /* Everything was tested. Exit. */ if(node_id == my_test_node_id) { vrs_send_connect_terminate(session_id); } }
static void handle_signal(int sig) { if(sig == SIGINT) { if(ctx != NULL) { printf("%s() try to terminate connection: %d\n", __FUNCTION__, ctx->verse.session_id); vrs_send_connect_terminate(ctx->verse.session_id); } else { exit(EXIT_FAILURE); } /* Reset signal handling to default behavior */ signal(SIGINT, SIG_DFL); } }
static void handle_signal(int sig) { if(sig == SIGINT) { if(ctx != NULL) { printf("%s() try to terminate connection: %d\n", __FUNCTION__, ctx->verse.session_id); /* Try to delete particle sender node */ vrs_send_node_destroy(ctx->verse.session_id, VRS_DEFAULT_PRIORITY, ctx->sender->sender_node->node_id); /* Terminate connection */ vrs_send_connect_terminate(ctx->verse.session_id); } else { exit(EXIT_FAILURE); } /* Reset signal handling to default behavior */ signal(SIGINT, SIG_DFL); } }