From 342045e17750e755558616f7fd826470e9b11a7e Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 14 Dec 2009 10:13:36 -0800 Subject: [PATCH] ovs-vsctl: Add -t or --timeout option to limit runtime. --- utilities/ovs-vsctl.8.in | 6 ++++++ utilities/ovs-vsctl.c | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/utilities/ovs-vsctl.8.in b/utilities/ovs-vsctl.8.in index 1ea80b79a..0515760b2 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 9c019cc00..1ec497926 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; -- 2.43.0