ovs-vsctl: Add -t or --timeout option to limit runtime.
authorBen Pfaff <blp@nicira.com>
Mon, 14 Dec 2009 18:13:36 +0000 (10:13 -0800)
committerBen Pfaff <blp@nicira.com>
Mon, 14 Dec 2009 18:13:49 +0000 (10:13 -0800)
utilities/ovs-vsctl.8.in
utilities/ovs-vsctl.c

index 1ea80b7..0515760 100644 (file)
@@ -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
index 9c019cc..1ec4979 100644 (file)
@@ -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;