Exemplo n.º 1
0
static int do_site(void)
{
	int fd;
	int rv = -1;

	if (!cl.debug) {
		if (daemon(0, 0) < 0) {
			perror("daemon error");
			exit(EXIT_FAILURE);
		}
	}

	setup_logging();
	fd = lockfile();
	if (fd < 0)
		return fd;

	log_info("BOOTH cluster site daemon started");
	set_scheduler();
	set_oom_adj(-16);

	rv = loop(SITE);
	if (rv < 0)
		goto fail;

	unlink_lockfile(fd);
	close_logging();

	return 0;

fail:
	return -1;
}
Exemplo n.º 2
0
static int do_client(void)
{
	int rv = -1;

	setup_logging();

	switch (cl.op) {
	case OP_LIST:
		rv = do_list();
		break;

	case OP_GRANT:
		rv = do_grant();
		break;

	case OP_REVOKE:
		rv = do_revoke();
		break;
	}
	
	close_logging();

	return rv;
}
Exemplo n.º 3
0
int main(int argc, char *const argv[])
{
	char *configfile = CONFIG_FILENAME;
	int c, rv = 0;
	struct watchdog_info ident;
	char *opts = "c:";
	struct option long_options[] = {
		{"config-file", required_argument, NULL, 'c'},
		{NULL, 0, NULL, 0}
	};
	int watchdog = -1;
	char *progname = basename(argv[0]);

	open_logging(progname, MSG_TO_STDERR);

	/* check for the one option we understand */
	while ((c = getopt_long(argc, argv, opts, long_options, NULL)) != EOF) {
		switch (c) {
		case 'c':
			configfile = optarg;
			break;
		default:
			usage(progname);
		}
	}

	read_config(configfile);

	/* this program has no other function than identifying the hardware behind
	 * this device i.e. if there is no device given we better punt */
	if (devname == NULL) {
		printf("No watchdog hardware configured in \"%s\"\n", configfile);
		exit(1);
	}

	/* open the device */
	watchdog = open(devname, O_WRONLY);
	if (watchdog == -1) {
		log_message(LOG_ERR, "cannot open %s (errno = %d = '%s')", devname, errno, strerror(errno));
		exit(1);
	}

	/* Print watchdog identity */
	if (ioctl(watchdog, WDIOC_GETSUPPORT, &ident) < 0) {
		log_message(LOG_ERR, "cannot get watchdog identity (errno = %d = '%s')", errno, strerror(errno));
		rv = 1;
	} else {
		ident.identity[sizeof(ident.identity) - 1] = '\0';	/* Be sure */
		printf("%s\n", ident.identity);
	}

	if (write(watchdog, "V", 1) < 0) {
		log_message(LOG_ERR, "write watchdog device gave error %d = '%s'!", errno, strerror(errno));
		rv = 1;
	}

	if (close(watchdog) == -1) {
		log_message(LOG_ALERT, "cannot close watchdog (errno = %d = '%s')", errno, strerror(errno));
		rv = 1;
	}

	close_logging();
	exit(rv);
}
Exemplo n.º 4
0
static __attribute__((destructor)) void deinitialize() {
	/* End logging */
	close_logging();
}