void sig_handler( int signal) { switch(signal) { case SIGINT: { AXIS2_LOG_INFO(system_env->log, "Received signal SIGINT. Server " "shutting down"); axis2_tcp_server_stop(server, system_env); AXIS2_LOG_INFO(system_env->log, "Shutdown complete ..."); system_exit(system_env, 0); } case SIGPIPE: { AXIS2_LOG_INFO(system_env->log, "Received signal SIGPIPE. Client " "request serve aborted"); return; } case SIGSEGV: { fprintf(stderr, "Received deadly signal SIGSEGV. Terminating\n"); _exit(-1); } } }
int main(void) { extern int kernel_main(bool system_main_init_stat); // 只能在main() 内使用 system_init(); kernel_main(true); system_exit(); }
void reset_handler(void) { volatile uint32_t *src, *dst; /* Workaround for PM debug issue */ HWREG(SYS_CTRL_EMUOVR) = 0xFF; /* Workaround for J-Link debug issue */ HWREG(NVIC_VTABLE) = (uint32_t)interrupt_vector; /* Copy the data segment initializers from flash to SRAM */ for (src = &_text_end, dst = &_data_start; dst < &_data_end; ) { *dst++ = *src++; } /* Initialize the BSS section to zero */ for (dst = &_bss_start; dst < &_bss_end; *dst++) { *dst = 0; } /* Initialize the system */ system_init(); /* Initialize standard C library */ __libc_init_array(); /* Call the application's entry point */ main(); /* End here if return from main() */ system_exit(); }
void Client::_sig_handler(int sig_num) { client_send_packet_s packet; packet.header.msg_id = client_send_packet_s::message_header_s::e_msg_id::KILL; packet.header.client_uuid = _uuid; packet.payload.kill_msg.cmd_id = sig_num; packet.header.payload_length = sizeof(packet.payload.kill_msg.cmd_id); if (_client_send_pipe_fd < 0) { PX4_ERR("pipe open fail"); system_exit(-1); } int bytes_to_send = get_client_send_packet_length(&packet); int bytes_sent = write(_client_send_pipe_fd, &packet, bytes_to_send); if (bytes_sent != bytes_to_send) { PX4_ERR("write fail"); system_exit(-1); } }
//------------------------------------------------------------------------------ int main(int argc, char** argv) { tOplkError ret = kErrorOk; tOptions opts; getOptions(argc, argv, &opts); #if defined(__COBALT__) mlockall(MCL_CURRENT | MCL_FUTURE); #endif if (system_init() != 0) { fprintf(stderr, "Error initializing system!"); return 0; } initEvents(&fGsOff_l); printf("----------------------------------------------------\n"); printf("openPOWERLINK console MN DEMO application\n"); printf("using openPOWERLINK Stack: %s\n", PLK_DEFINED_STRING_VERSION); printf("----------------------------------------------------\n"); if ((ret = initPowerlink(CYCLE_LEN, opts.cdcFile, aMacAddr_g)) != kErrorOk) goto Exit; if ((ret = initApp()) != kErrorOk) goto Exit; loopMain(); Exit: shutdownPowerlink(); shutdownApp(); system_exit(); return 0; }
//------------------------------------------------------------------------------ int main (int argc, char** argv) { tOplkError ret = kErrorOk; tOptions opts; getOptions(argc, argv, &opts); if (system_init() != 0) { fprintf(stderr, "Error initializing system!"); return 0; } initEvents(&fGsOff_l); printf("----------------------------------------------------\n"); printf("openPOWERLINK console CN DEMO application\n"); printf("using openPOWERLINK Stack: %s\n", PLK_DEFINED_STRING_VERSION); printf("----------------------------------------------------\n"); if ((ret = initPowerlink(CYCLE_LEN, aMacAddr_l, opts.nodeId)) != kErrorOk) goto Exit; if ((ret = initApp()) != kErrorOk) goto Exit; loopMain(); Exit: shutdownPowerlink(); shutdownApp(); system_exit(); return 0; }
int main( int argc, char *argv[]) { axutil_allocator_t *allocator = NULL; axutil_env_t *env = NULL; extern char *optarg; extern int optopt; int c; int log_file_size = AXUTIL_LOG_FILE_SIZE; axutil_log_levels_t log_level = AXIS2_LOG_LEVEL_DEBUG; const axis2_char_t *log_file = AXIS2_TCP_SERVER_LOG_FILE_NAME; int port = AXIS2_TCP_SERVER_PORT; const axis2_char_t *repo_path = AXIS2_TCP_SERVER_REPO_PATH; while((c = AXIS2_GETOPT(argc, argv, ":p:r:ht:l:s:f:")) != -1) { switch(c) { case 'p': port = AXIS2_ATOI(optarg); break; case 'r': repo_path = optarg; break; case 't': axis2_tcp_socket_read_timeout = AXIS2_ATOI(optarg) * 1000; break; case 'l': log_level = AXIS2_ATOI(optarg); if(log_level < AXIS2_LOG_LEVEL_CRITICAL) log_level = AXIS2_LOG_LEVEL_CRITICAL; if(log_level > AXIS2_LOG_LEVEL_TRACE) log_level = AXIS2_LOG_LEVEL_TRACE; break; case 's': log_file_size = 1024 * 1024 * AXIS2_ATOI(optarg); break; case 'f': log_file = optarg; break; case 'h': usage(argv[0]); return 0; case ':': fprintf(stderr, "\nOption -%c requires an operand\n", optopt); usage(argv[0]); return -1; case '?': if(isprint(optopt)) fprintf(stderr, "\nUnknown option `-%c'.\n", optopt); usage(argv[0]); return -1; } } allocator = axutil_allocator_init(NULL); if(!allocator) { system_exit(NULL, -1); } env = init_syetem_env(allocator, log_file); env->log->level = log_level; env->log->size = log_file_size; axutil_error_init(); system_env = env; #ifndef WIN32 signal(SIGINT, sig_handler); signal(SIGPIPE, sig_handler); #endif AXIS2_LOG_INFO(env->log, "Starting Axis2 TCP server...."); AXIS2_LOG_INFO(env->log, "Server port : %d", port); AXIS2_LOG_INFO(env->log, "Repo location : %s", repo_path); AXIS2_LOG_INFO(env->log, "Read Timeout : %d ms", axis2_tcp_socket_read_timeout); server = axis2_tcp_server_create(env, repo_path, port); if(!server) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Server creation failed: Error code:" " %d :: %s", env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error)); system_exit(env, -1); } printf("Started Simple Axis2 TCP Server ...\n"); if(axis2_transport_receiver_start(server, env) == AXIS2_FAILURE) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Server start failed: Error code:" " %d :: %s", env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error)); system_exit(env, -1); } return 0; }
void px4_systemreset(bool to_bootloader) { PX4_WARN("Called px4_system_reset"); system_exit(0); }