i32 clean_up() { i32 ret = PASS; ret = remove_message_queue(); if(ret == PASS){ app2_log("Success in removing all the mesasge queue\n"); } else { app2_elog("Error in removing all the message queue\n"); } return ret; }
/** * sets up the message queue, and listens for clients to connect. * * @function main * * @date 2015-02-10 * * @revision none * * @designer EricTsang * * @programmer EricTsang * * @note none * * @signature int main(void) * * @return return code, indication the nature of process termination. */ int main(void) { int exitCode; /* set up signal handler to remove IPC. */ previousSigHandler = signal(SIGINT, sigint_handler); /* create the message queue. */ make_message_queue(&msgQId); /* execute main loop of the server. */ exitCode = msgq_read_loop(msgQId); /* remove message queue. */ remove_message_queue(msgQId); /* end program... */ return exitCode; }
/** * signal enqueues a stop server message into the server's message queue. * * @function sigint_handler * * @date 2015-02-10 * * @revision none * * @designer EricTsang * * @programmer EricTsang * * @note * * signal enqueues a stop server message into the server's message queue, so * that when the server parses the message, it will break out of the server * loop, and end normally. * * @signature static int sigint_handler(int sigNum) * * @param sigNum type of signal received */ static void sigint_handler(int sigNum) { remove_message_queue(msgQId); exit(sigNum); }