From: Ben Pfaff Date: Mon, 14 Dec 2009 18:13:36 +0000 (-0800) Subject: ovs-vsctl: Add -t or --timeout option to limit runtime. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=342045e17750e755558616f7fd826470e9b11a7e;p=openvswitch ovs-vsctl: Add -t or --timeout option to limit runtime. --- diff --git a/utilities/ovs-vsctl.8.in b/utilities/ovs-vsctl.8.in index 1ea80b79..0515760b 100644 --- a/utilities/ovs-vsctl.8.in +++ b/utilities/ovs-vsctl.8.in @@ -99,6 +99,12 @@ Prints a blank line for each command that has no output. .IP "\fB\-\-dry\-run\fR" Prevents \fBovs\-vsctl\fR from actually modifying the database. . +.IP "\fB-t \fIsecs\fR" +.IQ "\fB--timeout=\fIsecs\fR" +Limits runtime to approximately \fIsecs\fR seconds. If the timeout +expires, \fBovs\-vsctl\fR will exit with a \fBSIGALRM\fR signal. +(This would normally happen only if the database cannot be contacted.) +. .so lib/vlog.man . .SH COMMANDS diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 9c019cc0..1ec49792 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -150,16 +150,19 @@ parse_options(int argc, char *argv[]) {"no-wait", no_argument, 0, OPT_NO_WAIT}, {"dry-run", no_argument, 0, OPT_DRY_RUN}, {"oneline", no_argument, 0, OPT_ONELINE}, + {"timeout", required_argument, 0, 't'}, {"verbose", optional_argument, 0, 'v'}, {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'V'}, {0, 0, 0, 0}, }; + for (;;) { + unsigned long int timeout; int c; - c = getopt_long(argc, argv, "+v::hV", long_options, NULL); + c = getopt_long(argc, argv, "+v::hVt:", long_options, NULL); if (c == -1) { break; } @@ -192,6 +195,16 @@ parse_options(int argc, char *argv[]) OVS_PRINT_VERSION(0, 0); exit(EXIT_SUCCESS); + case 't': + timeout = strtoul(optarg, NULL, 10); + if (timeout <= 0) { + ovs_fatal(0, "value %s on -t or --timeout is not at least 1", + optarg); + } else { + time_alarm(timeout); + } + break; + case 'v': vlog_set_verbosity(optarg); break;