static void signal_handler(int sig) { if (running) { log_info("Signal received, shutting down"); running = 0; ipc_notify(killsocket); } else { log_fatal("Another signal received, killing process"); kill(getpid(), SIGKILL); ipc_notify(killsocket); } }
int main() { struct ipc_message m; struct calc_msg cm; while(ipc_receive(IPC_ANY,&m)==IPC_SUCCESS) { //mem_copy((addr_t)m.data,(addr_t)&cm,sizeof(struct calc_msg)); switch(cm.op_code) { case 1: cm.op_res = cm.op_1 + cm.op_2; break; case 2: cm.op_res = cm.op_1 * cm.op_2; break; default: cm.op_res = 0; } //mem_copy((addr_t)&cm,(addr_t)m.data,sizeof(struct calc_msg)); ipc_notify(m.from); ipc_send(m.from,&m); } //while(1){} return 0; }