int timelimit;
uint32_t pnn;
int machinereadable;
+ int maxruntime;
} options;
#define TIMELIMIT() timeval_current_ofs(options.timelimit, 0)
}
+static void ctdb_alarm(int sig)
+{
+ printf("Maximum runtime exceeded - exiting\n");
+ _exit(0);
+}
+
/*
main program
*/
{ "timelimit", 't', POPT_ARG_INT, &options.timelimit, 0, "timelimit", "integer" },
{ "node", 'n', POPT_ARG_STRING, &nodestring, 0, "node", "integer|all" },
{ "machinereadable", 'Y', POPT_ARG_NONE, &options.machinereadable, 0, "enable machinereadable output", NULL },
+ { "maxruntime", 'T', POPT_ARG_INT, &options.maxruntime, 0, "die if runtime exceeds this limit (in seconds)", "integer" },
POPT_TABLEEND
};
int opt;
setlinebuf(stdout);
/* set some defaults */
+ options.maxruntime = 0;
options.timelimit = 3;
options.pnn = CTDB_CURRENT_NODE;
usage();
}
+ if (options.maxruntime != 0) {
+ signal(SIGALRM, ctdb_alarm);
+ alarm(options.maxruntime);
+ }
+
/* setup the node number to contact */
if (nodestring != NULL) {
if (strcmp(nodestring, "all") == 0) {