int main(int argc, char** argv) { if (argc != 2) { fprintf(stderr, "usage: %s <config-file>\n", argv[0]); exit(1); } int result = 0; // Call qd_dispatch() first initialize allocator used by other tests. qd_dispatch_t *qd = qd_dispatch(0); qd_dispatch_load_config(qd, argv[1]); if (qd_error_code()) { printf("Config failed: %s\n", qd_error_message()); return 1; } result += timer_tests(); result += server_tests(qd); result += tool_tests(); result += parse_tests(); result += compose_tests(); #if USE_MEMORY_POOL result += alloc_tests(); #endif result += policy_tests(); qd_dispatch_free(qd); // dispatch_free last. return result; }
static void main_process(const char *config_path, const char *python_pkgdir, int fd) { dispatch = qd_dispatch(python_pkgdir); check(fd); log_source = qd_log_source("MAIN"); /* Logging is initialized by qd_dispatch. */ qd_dispatch_validate_config(config_path); check(fd); qd_dispatch_load_config(dispatch, config_path); check(fd); signal(SIGHUP, signal_handler); signal(SIGQUIT, signal_handler); signal(SIGTERM, signal_handler); signal(SIGINT, signal_handler); if (fd > 2) { /* Daemon mode, fd is one end of a pipe not stdout or stderr */ #ifdef __sun const char * okResult = "ok"; write(fd, okResult, (strlen(okResult)+1)); #else dprintf(fd, "ok"); // Success signal #endif close(fd); } qd_server_run(dispatch); qd_dispatch_t *d = dispatch; dispatch = NULL; qd_dispatch_free(d); fflush(stdout); if (exit_with_sigint) { signal(SIGINT, SIG_DFL); kill(getpid(), SIGINT); } }