Beispiel #1
0
/**
 * sighup_handler
 * @brief signal handler for SIGHUP
 *
 * The SIGHUP signal will cause the rtas_errd daemon to re-read
 * the configuration file.  If it is currently safe to re-configure
 * ourselves we do, otherwise we set a flag to indicate that a
 * re-configuration needs to occur at the next "safe" place
 */
void
sighup_handler(int sig, siginfo_t siginfo, void *context)
{
	if (d_cfg.flags & RE_CFG_RECFG_SAFE)
		diag_cfg(1, &cfg_log);
	else
		d_cfg.flags |= RE_CFG_RECEIVED_SIGHUP;
}
int
main(int argc, char *argv[])
{
	int option_index, rc, fail=0;
	int platform = 0;
	uint64_t dump_tag;

	platform = get_platform();
	switch (platform) {
	case PLATFORM_UNKNOWN:
	case PLATFORM_POWERKVM:
		fprintf(stderr, "%s: is not supported on the %s platform\n",
				argv[0], __power_platform_name(platform));
		return -1;
	}

	for (;;) {
		option_index = 0;
		rc = getopt_long(argc, argv, "hv", long_options,
				&option_index);

		if (rc == -1)
			break;

		switch (rc) {
		case 'h':
			print_usage(argv[0]);
			return 0;
		case 'v':
			flag_v = 1;
			break;
		case '?':
			print_usage(argv[0]);
			return -1;
			break;
		default:
			printf("huh?\n");
			break;
		}
	}

	if (optind < argc) {
		/* Parse ppc64-diag config file */
		rc = diag_cfg(0, &msg);
		if (rc) {
			fprintf(stderr, "Could not parse configuration file "
				"%s\n", config_file);
			return -2;
		}

		while (optind < argc) {
			dump_tag = strtoll(argv[optind++], NULL, 16);
			fail += extract_platform_dump(dump_tag);
		}
	}
	else {
		fprintf(stderr, "No dump tag specified\n");
		print_usage(argv[0]);
		return -1;
	}

	return fail;
}