ovsdb-client: Add support for --detach to "monitor" command.
authorBen Pfaff <blp@nicira.com>
Thu, 3 Dec 2009 22:25:06 +0000 (14:25 -0800)
committerBen Pfaff <blp@nicira.com>
Thu, 3 Dec 2009 22:47:00 +0000 (14:47 -0800)
ovsdb/ovsdb-client.1.in
ovsdb/ovsdb-client.c

index 9825d32..82a9919 100644 (file)
@@ -29,6 +29,7 @@ ovsdb\-client \- command-line interface to \fBovsdb-server\fR(1)
 [\fB--format=\fIformat\fR]
 [\fB--wide\fR]
 [\fB--no-heading\fR]
+.so lib/daemon-syn.man
 .so lib/vlog-syn.man
 .so lib/common-syn.man
 .
@@ -88,6 +89,10 @@ Print deleted rows.
 .IP "\fBmodify\fR"
 Print old and new values of modified rows.
 .RE
+.IP
+If \fB--detach\fR is used with \fBmonitor\fR, then \fBovsdb\-client\fR
+detaches after it has successfully received and printed the initial
+contents of \fItable\fR.
 .SH OPTIONS
 .SS "Output Formatting Options"
 Much of the output from \fBovsdb\-client\fR is in the form of tables.
@@ -115,6 +120,12 @@ characters.  Specifying this option prevents line truncation.
 This option suppresses the heading row that otherwise appears in the
 first row of table output.
 .
+.SS "Daemon Options"
+The daemon options apply only to the \fBmonitor\fR command.  With any
+other command, they have no effect.
+.so lib/daemon.man
+.SS "Logging Options"
+.so lib/vlog.man
 .SS "Logging Options"
 .so lib/vlog.man
 .SS "Other Options"
index 65d6d81..0991e71 100644 (file)
@@ -27,6 +27,7 @@
 #include "command-line.h"
 #include "column.h"
 #include "compiler.h"
+#include "daemon.h"
 #include "dynamic-string.h"
 #include "json.h"
 #include "jsonrpc.h"
@@ -80,6 +81,7 @@ parse_options(int argc, char *argv[])
         {"verbose", optional_argument, 0, 'v'},
         {"help", no_argument, 0, 'h'},
         {"version", no_argument, 0, 'V'},
+        DAEMON_LONG_OPTIONS,
         {0, 0, 0, 0},
     };
     char *short_options = long_options_to_short_options(long_options);
@@ -121,6 +123,8 @@ parse_options(int argc, char *argv[])
             vlog_set_verbosity(optarg);
             break;
 
+        DAEMON_OPTION_HANDLERS
+
         case '?':
             exit(EXIT_FAILURE);
 
@@ -160,6 +164,7 @@ usage(void)
            "                              (\"table\", \"html\", or \"csv\"\n"
            "  --wide                      don't limit TTY lines to 79 bytes\n"
            "  --no-headings               omit table heading row\n");
+    daemon_usage();
     vlog_usage();
     printf("\nOther options:\n"
            "  -h, --help                  display this help message\n"
@@ -814,6 +819,8 @@ do_monitor(int argc, char *argv[])
         } else if (msg->type == JSONRPC_REPLY
                    && json_equal(msg->id, request_id)) {
             monitor_print(msg->result, table, &columns, true);
+            fflush(stdout);
+            daemonize();
         } else if (msg->type == JSONRPC_NOTIFY
                    && !strcmp(msg->method, "update")) {
             struct json *params = msg->params;
@@ -822,6 +829,7 @@ do_monitor(int argc, char *argv[])
                 && params->u.array.elems[0]->type == JSON_NULL) {
                 monitor_print(params->u.array.elems[1],
                               table, &columns, false);
+                fflush(stdout);
             }
         }
     }