int main()

in src/main.c [603:673]


int main(int argc, char **argv)
{
	int err_code = NO_ERR;
	struct lagscope_test *test;
	struct lagscope_test_server *server;
	struct lagscope_test_client *client;

	/* catch SIGINT: Ctrl + C */
	if (signal(SIGINT, sig_handler) == SIG_ERR)
		PRINT_ERR("main: error when setting the disposition of the signal SIGINT");

	print_version();
	test = new_lagscope_test();
	if (!test) {
		PRINT_ERR("main: error when creating new test");
		exit (-1);
	}

	default_lagscope_test(test);
	err_code = parse_arguments(test, argc, argv);
	if (err_code != NO_ERR) {
		PRINT_ERR("main: error when parsing args");
		print_flags(test);
		free(test);
		exit (-1);
	}

	err_code = verify_args(test);
	if (err_code != NO_ERR) {
		PRINT_ERR("main: error when verifying the args");
		print_flags(test);
		free(test);
		exit (-1);
	}

	if (test->verbose)
		print_flags(test);

	turn_off_light();

	if (test->cpu_affinity != -1) {
		if (!set_affinity(test->cpu_affinity)) {
			PRINT_ERR("main: failed to set cpu affinity");
			exit (-1);
		}
	}

	if (test->daemon) {
#ifndef _WIN32
		PRINT_INFO("main: run this tool in the background");
		if (daemon(0, 0) != 0)
			PRINT_ERR("main: cannot run this tool in the background");
#else
		test->daemon = 0;
		PRINT_INFO("main: run in background: Lagscope currently do not support this option in Windows ");
#endif
	}

	if (test->client_role == true) {
		client = new_lagscope_client(test);
		err_code = run_lagscope_sender(client);
		free(client);
	}
	else {
		server = new_lagscope_server(test);
		err_code = run_lagscope_receiver(server);
		free(server);
	}

	return err_code;
}